Skip to content

develephant/corona-html5-windowSize-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Releases

No releases published

Packages

No packages published