Module: hcje/device

Various utilities for managing the device the app is running on. In this context, the window size is also regarded as device information as not controlled by the app itself and more represents the environment in which it is running.

Source:

Classes

Keyboard

Methods

(static) enterFullscreen(elementopt, optionsopt)

Put the element into fullscreen mode.

Parameters:
Name Type Attributes Default Description
element Element <optional>
Document.documentElement

The element to go into fullscreen.

options Object <optional>

See requestFullscreen options

Source:

(static) exitFullscreen()

Exit fullscreen mode.

Source:

(static) getDimensions(elementopt) → {Object}

Get the dimensions of an element.

Parameters:
Name Type Attributes Default Description
element Element <optional>
window

Element to check. Defaults to the window.

Source:
Returns:
Type
Object

(static) getScaleToCover(width, height, options) → {number}

Get an appropriate scale to allow a rectangle to cover the body. The body should have been set in css to fit the screen.

Parameters:
Name Type Description
width number

Rectangle width

height height

Rectangle height

options Object
Properties
Name Type Description
margin number

Margin around rectangle

element Element

Element to use for bounds. Defaults to window innerWidth;

Source:
Returns:
Type
number

(static) getScaleToFit(width, height, options) → {number}

Get an appropriate scale to allow a rectangle to fit in the body. The body should have been set in css to fit the screen.

Parameters:
Name Type Description
width number

Rectangle width

height height

Rectangle height

options Object
Properties
Name Type Description
margin number

Margin around rectangle

element Element

Element to use for bounds. Defaults to window innerWidth;

Source:
Returns:
Type
number

(static) getScaleToFitOrCover(width, height, cover, options) → {number}

Get an appropriate scale to allow a rectangle to fit in the body. Typically no element is provided and the body will have been set in css to fit the screen.

Parameters:
Name Type Description
width number

Rectangle width

height height

Rectangle height

cover boolean

Should scale result in the rectangle covering the element or fitting within it. Fits if false.

options Object
Properties
Name Type Description
margin number

Margin around the rectangle.

element Element

Element to use for bounds. Defaults to using the window.

Source:
Returns:
Type
number

(static) supportsTouch() → {boolean}

Test if touch api supported.

Source:
Returns:
Type
boolean

Type Definitions

KeyEventListener

Type:
  • Object
Properties:
Name Type Description
callback function

Function to call on event

noRepeat boolean

If true, key repeats are ignored.

Source:

VirtualKeyDetail

Detail provided in the details property of the options object provided to the CustomEvent.

Type:
  • Object
Properties:
Name Type Description
key string

see the KeyboardEvent.key property.

Source: