4.0.2 • Published 3 years ago

wtc-utility-helpers v4.0.2

Weekly downloads
194
License
MIT
Repository
github
Last release
3 years ago

Functions

floatRandomBetween(min, max) ⇒ number

Kind: global function
Returns: number - Random number.

ParamTypeDescription
minnumberMinimum value.
maxnumberMaximum value.

randomBetween(min, max) ⇒ number

Kind: global function
Returns: number - Random number.

ParamTypeDescription
minnumberMinimum value.
maxnumberMaximum value.

lerp(x, y, amount) ⇒ number

Kind: global function
Returns: number - The interpolated value

ParamTypeDescription
xnumberThe lower value
ynumberThe upper value
amountnumberthe 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

ParamTypeDescription
minnumberThe lower bound
maxnumberThe upper bound
valuenumberThe value to clamp.

shuffleArray(array, modifyOriginal) ⇒ array

Kind: global function
Returns: array - Shuffled array.

ParamTypeDescription
arrayArrayArrray to be shuffled.
modifyOriginalBooleanA 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

ParamTypeDescription
namestringName of the event.
dataobjectObject to be passed to the event.
bubblesBooleanIndicates whether the event bubbles (default True)
cancelableBooleanIndicates whether the event is cancellable default True)

getElementPosition(element, toWorld) ⇒ Object

Kind: global function
Returns: Object - the element coordinates.

ParamTypeDescription
elementDOMNodeElement.
toWorldBooleanindicates 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

ParamTypeDescription
elementDomNodeThe element to test with
parentElementDomNodeThe parent element to test against
toWorldBooleanWhether to test this up the DOM hierarchy

getSiblings(e) ⇒

Kind: global function
Returns: Returns a list with the element's siblings.

ParamTypeDescription
eDOMElementElement

getAncestors(e, toBody, ancestors)

Kind: global function

ParamTypeDescription
eDOMElementThe element to retrieve the ancestors for
toBodybooleanwhether to only test to the body (default True)
ancestorsarraythe 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

ParamTypeDescription
elDOMElementThe DOM node to find a selector for

fixWidows()

Kind: global function

serializeArray(form) ⇒ Array

Kind: global function
Returns: Array - Serialized data

ParamTypeDescription
formDOMElementThe DOM node

asyncImageLoadfunction(props) ⇒ Promise

Kind: global function
Returns: Promise - A promise

ParamTypeDescription
propsObjectImage properties
props.srcStringThe image SRC

floatRandomBetween(min, max) ⇒ number

Kind: global function
Returns: number - Random number.

ParamTypeDescription
minnumberMinimum value.
maxnumberMaximum value.

randomBetween(min, max) ⇒ number

Kind: global function
Returns: number - Random number.

ParamTypeDescription
minnumberMinimum value.
maxnumberMaximum value.

lerp(x, y, amount) ⇒ number

Kind: global function
Returns: number - The interpolated value

ParamTypeDescription
xnumberThe lower value
ynumberThe upper value
amountnumberthe 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

ParamTypeDescription
minnumberThe lower bound
maxnumberThe upper bound
valuenumberThe value to clamp.

shuffleArray(array, modifyOriginal) ⇒ array

Kind: global function
Returns: array - Shuffled array.

ParamTypeDescription
arrayArrayArrray to be shuffled.
modifyOriginalBooleanA 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

ParamTypeDescription
namestringName of the event.
dataobjectObject to be passed to the event.
bubblesBooleanIndicates whether the event bubbles (default True)
cancelableBooleanIndicates whether the event is cancellable default True)

getElementPosition(element, toWorld) ⇒ Object

Kind: global function
Returns: Object - the element coordinates.

ParamTypeDescription
elementDOMNodeElement.
toWorldBooleanindicates 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

ParamTypeDescription
elementDomNodeThe element to test with
parentElementDomNodeThe parent element to test against
toWorldBooleanWhether to test this up the DOM hierarchy

getSiblings(e) ⇒

Kind: global function
Returns: Returns a list with the element's siblings.

ParamTypeDescription
eDOMElementElement

getAncestors(e, toBody, ancestors)

Kind: global function

ParamTypeDescription
eDOMElementThe element to retrieve the ancestors for
toBodybooleanwhether to only test to the body (default True)
ancestorsarraythe 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

ParamTypeDescription
elDOMElementThe DOM node to find a selector for

fixWidows()

Kind: global function

serializeArray(form) ⇒ Array

Kind: global function
Returns: Array - Serialized data

ParamTypeDescription
formDOMElementThe DOM node

asyncImageLoadfunction(props) ⇒ Promise

Kind: global function
Returns: Promise - A promise

ParamTypeDescription
propsObjectImage properties
props.srcStringThe image SRC
4.0.1

3 years ago

4.0.2

3 years ago

3.1.0

3 years ago

3.0.1

4 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.9

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago