⁘ utils

UTILS_DOM

UTILS_DOM is a wrapper class that contains a bunch of utilitary static methods to manipulate the DOM. Since the NKMjs library isn't heavy on DOM manipulation, these are mostly shortcut to common operations such as additions & deletions

go to → Members

Methods

staticAttach(p_element, p_parent)

Appends a dom element into another one

Parameters:
Name Type Description
p_element Node

The element to be appended

p_parent Node

Parent node to append the element into

staticAttachFirst(p_element, p_parent, p_firstChildopt)

Appends or move an element at the beginning of the display list of another dom element. Note that if the element provided is not a child of the target parent, it will be removed from its previous parent.

Parameters:
Name Type Attributes Default Description
p_element Node

The element to be appended or moved

p_parent Node

Parent node to append or move the element into

p_firstChild boolean <optional>
true

If true, attach before the firstChild, otherwise attach before the firstChildElement

staticDetach(p_element)

Remove a node from its parent, if any

Parameters:
Name Type Description
p_element Node

staticNew(p_element, p_attributesopt, p_containeropt)

Create a DOM Node of a given type with a given set of attributes.

Parameters:
Name Type Attributes Default Description
p_element string
p_attributes object <optional>
null

inlined attributes & values

p_container Node <optional>
null

Parent node to append the new node into

Examples:
let newNode = UTILS_DOM.New(`div`, { class:`foo`, ['data-title']:`bar` });
newNode == <div class="foo" data-title:"bar"></div> //dom element

staticNewClone(p_element, p_containeropt)

Create a clone of an existing DOM element.

Parameters:
Name Type Attributes Default Description
p_element Node

Node to clone

p_container Node <optional>
null

Parent node to append the new node into

staticOverflowsX(p_element) → {boolean}

TODO

Parameters:
Name Type Description
p_element Node

staticOverflowsY(p_element) → {boolean}

TODO

Parameters:
Name Type Description
p_element Node

staticslowRect(p_element, p_relativeopt)

Returns the bouding client rect of a given element, and if provided, relative to another dom element.

Parameters:
Name Type Attributes Default Description
p_element Node
p_relative Node <optional>
null

staticToBack(p_node, p_backOfNodeopt)

Move a node at the beginning (back) of the child list

Parameters:
Name Type Attributes Default Description
p_node Node
p_backOfNode boolean <optional>
false

If true, move the node at the back of the first child. Otherwise first childElement.

staticToFront(p_node, p_frontOfNodeopt)

Move a node at the end (front) of the child list

Parameters:
Name Type Attributes Default Description
p_node Node
p_frontOfNode boolean <optional>
false

If true, move the node at the front of the last child. Otherwise last childElement.