Get browser window sizing information on demand or via event.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo
icons
plugin
LICENSE
README.md

README.md

logo Corona HTML5 Window Size Plugin

Get browser window sizing information on demand or via event.

Browser Tests

chrome ie firefox safari opera
pass untested pass pass untested

Windows browser unconfirmed.

Installation

  • Download the Corona HTML5 Window Size Plugin respository.
  • Move plugin/windowSize.lua and plugin/windowSize_js.js to the root of your HTML5 project.
  • Require the plugin in your code where you need it.
local windowSize = require("windowSize")

API

getSize

Returns a Table of the browser window size properties, or a Number if property is supplied.

windowSize.getSize([property])

Properties

  • innerWidth
  • innerHeight
  • outerWidth
  • outerHeight
  • screenLeft
  • screenTop

Example

Direct access

local windowSize = require("windowSize")

local info = windowSize.getSize()

print(info.innerWidth) --> 960

Direct access (via property)

local windowSize = require("windowSize")

local innerHeight = windowSize.getSize('innerHeight')

print(innerHeight) --> 960

Event listener

local windowSize = require("windowSize")

local function onBrowserResize()
  local info = windowSize.getSize()

  print(info.innerWidth) --> 1020
end

Runtime:addEventListener( "resize", onBrowserResize )

Demo

A Corona project can be found in the demo directory that can be compiled to an HTML5 build for testing.


©2018 C. Byerley (develephant)