DOM.getBounds()

<static> getBounds(element, cushion) → {Object | boolean}

A cross-browser element.getBoundingClientRect method with optional cushion.

Returns a plain object containing the properties top/bottom/left/right/width/height with respect to the top-left corner of the current viewport.
Its properties match the native rectangle.
The cushion parameter is an amount of pixels (+/-) to cushion the element.
It adjusts the measurements such that it is possible to detect when an element is near the viewport.

Parameters
Name Type Argument Description
element DOMElement | Object

The element or stack (uses first item) to get the bounds for.

cushion number <optional>

A +/- pixel adjustment amount.

Returns
Object | boolean -

A plain object containing the properties top/bottom/left/right/width/height or false if a non-valid element is given.

Source code: utils/DOM.js (Line 48)
doc_phaser
2017-02-14 10:45:00
Comments
Leave a Comment

Please login to continue.