ionic.DomUtil
Methods
requestAnimationFrame(callback)(alias: ionic.requestAnimationFrame)
Calls requestAnimationFrame, or a polyfill if not available.
| Param | Type | Details |
|---|---|---|
| callback |
function
|
The function to call when the next frame happens. |
animationFrameThrottle(callback)(alias: ionic.animationFrameThrottle)
When given a callback, if that callback is called 100 times between animation frames, adding Throttle will make it only run the last of the 100 calls.
| Param | Type | Details |
|---|---|---|
| callback |
function
|
a function which will be throttled to requestAnimationFrame |
- Returns:
functionA function which will then call the passed in callback. The passed in callback will receive the context the returned function is called with.
getPositionInParent(element)
Find an element’s scroll offset within its container.
| Param | Type | Details |
|---|---|---|
| element |
DOMElement
|
The element to find the offset of. |
- Returns:
objectA position object with the following properties:{number}leftThe left offset of the element.{number}topThe top offset of the element.
ready(callback)
Call a function when the DOM is ready, or if it is already ready call the function immediately.
| Param | Type | Details |
|---|---|---|
| callback |
function
|
The function to be called. |
getTextBounds(textNode)
Get a rect representing the bounds of the given textNode.
| Param | Type | Details |
|---|---|---|
| textNode |
DOMElement
|
The textNode to find the bounds of. |
- Returns:
objectAn object representing the bounds of the node. Properties:{number}leftThe left position of the textNode.{number}rightThe right position of the textNode.{number}topThe top position of the textNode.{number}bottomThe bottom position of the textNode.{number}widthThe width of the textNode.{number}heightThe height of the textNode.
getChildIndex(element, type)
Get the first index of a child node within the given element of the specified type.
| Param | Type | Details |
|---|---|---|
| element |
DOMElement
|
The element to find the index of. |
| type |
string
|
The nodeName to match children of element against. |
- Returns:
numberThe index, or -1, of a child with nodeName matching type.
getParentWithClass(element, className)
| Param | Type | Details |
|---|---|---|
| element |
DOMElement
|
|
| className |
string
|
- Returns:
DOMElementThe closest parent of element matching the className, or null.
getParentOrSelfWithClass(element, className)
| Param | Type | Details |
|---|---|---|
| element |
DOMElement
|
|
| className |
string
|
- Returns:
DOMElementThe closest parent or self matching the className, or null.
rectContains(x, y, x1, y1, x2, y2)
| Param | Type | Details |
|---|---|---|
| x |
number
|
|
| y |
number
|
|
| x1 |
number
|
|
| y1 |
number
|
|
| x2 |
number
|
|
| y2 |
number
|
- Returns:
booleanWhether {x,y} fits within the rectangle defined by {x1,y1,x2,y2}.
blurAll()
Blurs any currently focused input element
- Returns:
DOMElementThe element blurred or null