Gets window informations of the Web browser.
Build
Build this module:
$ gulp build
Usage
Load this module in a browser:
<script src="xslet.window.min.js"></script>
Use xslet.window.unitOfSize
:
xslet.window.unitOfSize = 'rem'
document.getElementById('id1').style.width = 10 + xslet.window.unitOfSize
Use xslet.window.rootFontSize
:
xslet.window.rootFontSize = '3.51mm'
xslet.window.rootFontSize
xslet.window.rootFontSize = 13
document.getElementById('id2').style.fontSize = '2rem'
Use xslet.window.convertUnit
:
xslet.window.rootFontSize = 13
xslet.window.convertUnit(2, 'rem', 'px')
APIs
xslet.window.unitOfSize
The unit which used in xslet modules.
This value allowed are 'px'
, 'mm'
and 'rem'
and can be set only once.
Type: string
xslet.window.rootFontSize
The font size which is assigned to the HTML element.
This value is a number and the unit of this property is 'px'
, but can be set in unit either 'px'
or 'mm'
with a string like '10px'
or '2mm'
.
Type: number
xslet.window.convertUnit(value, fromUnit, toUnit)
Converts value
in fromUnit
to new value in toUnit
.
The units allowed are either 'px'
, 'mm'
and 'rem'
.
Parameter:
- value {number} : A value to be converted.
- fromUnit {string} : The unit of
value
. - toUnit {string} : The unit of value after converted.
Return:
- {number} : The value after converted.
License
Copyright (C) 2016 Takayuki Sato
This program is free software under MIT License.
See the file LICENSE in this distribution for more details.