Namespace: utils

requiem~utils

Utility methods.
Source:

Methods

(static) getIntersectRect() → {Object}

Computes the intersecting rect of 2 given elements. If only 1 element is specified, the other element will default to the current viewport.
Parameters:
Type Attributes Description
Node <repeatable>
Source:
Returns:
Object containing width, height.
Type
Object

(static) getRect(element, referenceopt) → {Object}

Gets the rect of a given element or the overall rect of an array of elements.
Parameters:
Name Type Attributes Default Description
element Node | Array.<Node>
reference Object <optional>
window
Source:
Returns:
Object containing top, left, bottom, right, width, height.
Type
Object

(static) getViewportRect() → {Object}

Gets the rect of the viewport (FOV).
Source:
Returns:
Object containing top, left, bottom, right, width, height.
Type
Object

(static) hitTestElement(obj, …elements) → {boolean}

Hit tests a vector or element against other elements.
Parameters:
Name Type Attributes Description
obj Object | Node
Properties
Name Type Description
x number
y number
elements Node <repeatable>
Source:
Returns:
True if test passes, false otherwise.
Type
boolean

(static) hitTestRect(obj, …rects) → {boolean}

Hit tests a vector or element against other elements.
Parameters:
Name Type Attributes Description
obj Object | Node
Properties
Name Type Description
x number
y number
rects Object <repeatable>
Properties
Name Type Description
top number
right number
bottom number
left number
Source:
Returns:
True if test passes, false otherwise.
Type
boolean

(static) transform(element, propertiesopt, constraintsopt) → {Object}

Transforms a DOM element.
Parameters:
Name Type Attributes Description
element Node | Array.<Node> Element(s) to perform the transform on.
properties Object <optional>
Transformation properties. (If unspecified, all transformation styles will be reset to 'initial').
Properties
Name Type Attributes Default Description
width number Target width of the element.
height number Target height of the element.
aspectRatio number Target aspect ratio of the element. If unspecified, it will be inferred from the original element.
unit string <optional>
'px' Unit of width/height values.
type string <optional>
'default' Resizing constraint: 'default', 'contain', 'cover'.
constraints Object <optional>
Transformation constraints.
contraints.width number <optional>
Bounded width of the element.
contraints.height number <optional>
Bounded height of the element.
Source:
Returns:
Transformed properties.
Type
Object

(static) translate(element, propertiesopt, constraintsopt) → {Object}

Translates a DOM element.
Parameters:
Name Type Attributes Description
element Node | Array.<Node> Element(s) to perform the 3D translation.
properties Object <optional>
Translation properties (if unspecified, all translation coordinates will be reset to 0).
Properties
Name Type Attributes Default Description
x number <optional>
X-coordinate.
y number <optional>
Y-coordinate.
z number <optional>
Z-coordinate.
units string <optional>
'px' Unit of translations.
constraints Object <optional>
Translation constraints.
Properties
Name Type Attributes Description
x number <optional>
Bounded x-coordinate.
y number <optional>
Bounded y-coordinate.
z number <optional>
Bounded z-coordinate.
Source:
Returns:
Translated properties.
Type
Object