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:
function
A 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:
object
A position object with the following properties:{number}
left
The left offset of the element.{number}
top
The 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:
object
An object representing the bounds of the node. Properties:{number}
left
The left position of the textNode.{number}
right
The right position of the textNode.{number}
top
The top position of the textNode.{number}
bottom
The bottom position of the textNode.{number}
width
The width of the textNode.{number}
height
The 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:
number
The index, or -1, of a child with nodeName matching type.
getParentWithClass(element, className)
Param | Type | Details |
---|---|---|
element |
DOMElement
|
|
className |
string
|
- Returns:
DOMElement
The closest parent of element matching the className, or null.
getParentOrSelfWithClass(element, className)
Param | Type | Details |
---|---|---|
element |
DOMElement
|
|
className |
string
|
- Returns:
DOMElement
The 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:
boolean
Whether {x,y} fits within the rectangle defined by {x1,y1,x2,y2}.
blurAll()
Blurs any currently focused input element
- Returns:
DOMElement
The element blurred or null