Get browser window sizing information on demand or via event.
Windows browser unconfirmed.
- 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")
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 )
A Corona project can be found in the demo directory that can be compiled to an HTML5 build for testing.
©2018 C. Byerley (develephant)