wtc-utility-helpers v4.0.2
Functions
floatRandomBetween(min, max) ⇒ number
Kind: global function
Returns: number - Random number.
| Param | Type | Description |
|---|---|---|
| min | number | Minimum value. |
| max | number | Maximum value. |
randomBetween(min, max) ⇒ number
Kind: global function
Returns: number - Random number.
| Param | Type | Description |
|---|---|---|
| min | number | Minimum value. |
| max | number | Maximum value. |
lerp(x, y, amount) ⇒ number
Kind: global function
Returns: number - The interpolated value
| Param | Type | Description |
|---|---|---|
| x | number | The lower value |
| y | number | The upper value |
| amount | number | the amount to interpolate. The expected value is a unit interval (a float between 0 and 1), but this will work with higher and lower values as well. |
clampfunction(min, max, value) ⇒ number
Kind: global function
Returns: number - A number in the range min, max
| Param | Type | Description |
|---|---|---|
| min | number | The lower bound |
| max | number | The upper bound |
| value | number | The value to clamp. |
shuffleArray(array, modifyOriginal) ⇒ array
Kind: global function
Returns: array - Shuffled array.
| Param | Type | Description |
|---|---|---|
| array | Array | Arrray to be shuffled. |
| modifyOriginal | Boolean | A boolean indicating whether the original array should be modified or whether a copy should be created. (default True) |
fireCustomEvent(name, data, bubbles, cancelable)
Kind: global function
| Param | Type | Description |
|---|---|---|
| name | string | Name of the event. |
| data | object | Object to be passed to the event. |
| bubbles | Boolean | Indicates whether the event bubbles (default True) |
| cancelable | Boolean | Indicates whether the event is cancellable default True) |
getElementPosition(element, toWorld) ⇒ Object
Kind: global function
Returns: Object - the element coordinates.
| Param | Type | Description |
|---|---|---|
| element | DOMNode | Element. |
| toWorld | Boolean | indicates whether the calculation of the element offset should be to the page or to the offset parent. (default True) |
isChildOf(element, parentElement, toWorld) ⇒ Boolean
Kind: global function
Returns: Boolean - true is the parentElement is parent (or ancestor) to Element
| Param | Type | Description |
|---|---|---|
| element | DomNode | The element to test with |
| parentElement | DomNode | The parent element to test against |
| toWorld | Boolean | Whether to test this up the DOM hierarchy |
getSiblings(e) ⇒
Kind: global function
Returns: Returns a list with the element's siblings.
| Param | Type | Description |
|---|---|---|
| e | DOMElement | Element |
getAncestors(e, toBody, ancestors)
Kind: global function
| Param | Type | Description |
|---|---|---|
| e | DOMElement | The element to retrieve the ancestors for |
| toBody | boolean | whether to only test to the body (default True) |
| ancestors | array | the list of already existing elements to pass. This is nromally only used internally |
getSelectorForElement(el) ⇒ String
Kind: global function
Returns: String - The CSS selector the describes exactly where to find the element
| Param | Type | Description |
|---|---|---|
| el | DOMElement | The DOM node to find a selector for |
fixWidows()
Kind: global function
serializeArray(form) ⇒ Array
Kind: global function
Returns: Array - Serialized data
| Param | Type | Description |
|---|---|---|
| form | DOMElement | The DOM node |
asyncImageLoadfunction(props) ⇒ Promise
Kind: global function
Returns: Promise - A promise
| Param | Type | Description |
|---|---|---|
| props | Object | Image properties |
| props.src | String | The image SRC |
floatRandomBetween(min, max) ⇒ number
Kind: global function
Returns: number - Random number.
| Param | Type | Description |
|---|---|---|
| min | number | Minimum value. |
| max | number | Maximum value. |
randomBetween(min, max) ⇒ number
Kind: global function
Returns: number - Random number.
| Param | Type | Description |
|---|---|---|
| min | number | Minimum value. |
| max | number | Maximum value. |
lerp(x, y, amount) ⇒ number
Kind: global function
Returns: number - The interpolated value
| Param | Type | Description |
|---|---|---|
| x | number | The lower value |
| y | number | The upper value |
| amount | number | the amount to interpolate. The expected value is a unit interval (a float between 0 and 1), but this will work with higher and lower values as well. |
clampfunction(min, max, value) ⇒ number
Kind: global function
Returns: number - A number in the range min, max
| Param | Type | Description |
|---|---|---|
| min | number | The lower bound |
| max | number | The upper bound |
| value | number | The value to clamp. |
shuffleArray(array, modifyOriginal) ⇒ array
Kind: global function
Returns: array - Shuffled array.
| Param | Type | Description |
|---|---|---|
| array | Array | Arrray to be shuffled. |
| modifyOriginal | Boolean | A boolean indicating whether the original array should be modified or whether a copy should be created. (default True) |
fireCustomEvent(name, data, bubbles, cancelable)
Kind: global function
| Param | Type | Description |
|---|---|---|
| name | string | Name of the event. |
| data | object | Object to be passed to the event. |
| bubbles | Boolean | Indicates whether the event bubbles (default True) |
| cancelable | Boolean | Indicates whether the event is cancellable default True) |
getElementPosition(element, toWorld) ⇒ Object
Kind: global function
Returns: Object - the element coordinates.
| Param | Type | Description |
|---|---|---|
| element | DOMNode | Element. |
| toWorld | Boolean | indicates whether the calculation of the element offset should be to the page or to the offset parent. (default True) |
isChildOf(element, parentElement, toWorld) ⇒ Boolean
Kind: global function
Returns: Boolean - true is the parentElement is parent (or ancestor) to Element
| Param | Type | Description |
|---|---|---|
| element | DomNode | The element to test with |
| parentElement | DomNode | The parent element to test against |
| toWorld | Boolean | Whether to test this up the DOM hierarchy |
getSiblings(e) ⇒
Kind: global function
Returns: Returns a list with the element's siblings.
| Param | Type | Description |
|---|---|---|
| e | DOMElement | Element |
getAncestors(e, toBody, ancestors)
Kind: global function
| Param | Type | Description |
|---|---|---|
| e | DOMElement | The element to retrieve the ancestors for |
| toBody | boolean | whether to only test to the body (default True) |
| ancestors | array | the list of already existing elements to pass. This is nromally only used internally |
getSelectorForElement(el) ⇒ String
Kind: global function
Returns: String - The CSS selector the describes exactly where to find the element
| Param | Type | Description |
|---|---|---|
| el | DOMElement | The DOM node to find a selector for |
fixWidows()
Kind: global function
serializeArray(form) ⇒ Array
Kind: global function
Returns: Array - Serialized data
| Param | Type | Description |
|---|---|---|
| form | DOMElement | The DOM node |
asyncImageLoadfunction(props) ⇒ Promise
Kind: global function
Returns: Promise - A promise
| Param | Type | Description |
|---|---|---|
| props | Object | Image properties |
| props.src | String | The image SRC |
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago