Methods
Attach(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 |
AttachFirst(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 |
Detach(p_element)
Remove a node from its parent, if any
Parameters:
| Name | Type | Description |
|---|---|---|
p_element |
Node |
New(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
NewClone(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 |
OverflowsX(p_element) → {boolean}
TODO
Parameters:
| Name | Type | Description |
|---|---|---|
p_element |
Node |
OverflowsY(p_element) → {boolean}
TODO
Parameters:
| Name | Type | Description |
|---|---|---|
p_element |
Node |
Rect(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
|
ToBack(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. |
ToFront(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. |