Module Utils

Animations

iterateAnimations

CSS: Altering

These functions transition an element from one CSS class to another, but could lead to forced layout if not scheduled using waitForMutateTime. If a delay is supplied, then the transition is "scheduled" and if the opposite transition is executed before the scheduled one, the original one is cancelled. See transitionElement for an example.

addClassesNow
delDataNow
displayElementNow
hideElementNow
removeClassesNow
setBooleanDataNow
setDataNow
showElementNow
toggleClassNow
toggleDisplayElementNow
toggleShowElementNow
transitionElementNow
undisplayElementNow
unsetBooleanDataNow

CSS: Altering (optimized)

These functions transition an element from one CSS class to another in an optimized way using waitForMutateTime and so are asynchronous. If a delay is supplied, then the transition is "scheduled" and if the opposite transition is executed before the scheduled one, the original one is cancelled. See transitionElement for an example.

addClasses
delData
displayElement
getBooleanData
getData
hasClass
hideElement
isElementHidden
isElementUndisplayed
removeClasses
setBooleanData
setData
showElement
toggleClass
toggleDisplayElement
toggleShowElement
transitionElement
undisplayElement
unsetBooleanData

DOM: Altering

These functions alter the DOM tree, but could lead to forced layout if not scheduled using waitForMutateTime.

delStylePropNow
getComputedStylePropNow
getStylePropNow
moveChildrenNow
moveElementNow
replaceElementNow
setStylePropNow
swapElementsNow
wrapChildrenNow
wrapElementNow

DOM: Altering (optimized)

These functions alter the DOM tree in an optimized way using waitForMutateTime and so are asynchronous.

delStyleProp
getComputedStyleProp
getStyleProp
hideAndRemoveElement
moveChildren
moveElement
replaceElement
setStyleProp
swapElements
wrapChildren
wrapElement

DOM: Events

isPageReady
waitForComplete
waitForElement
waitForElementOrInteractive
waitForInteractive
waitForPageReady

DOM: Preventing layout trashing

waitForMeasureTime allows you to schedule tasks that read or "measure", the DOM, for example getting computed styles, taking the offsetWidth or the scrollTop of an element, etc... anything that would force a layout if it runs after the layout has been invalidated by a "mutation".

See https://gist.github.com/paulirish/5d52fb081b3570c81e3 for a list of operations that should be run on a valid layout to avoid forced layouts.

waitForMutateTime allows you to schedule tasks that invalidate the DOM layout by making changes to the style, inserting or removing elements, etc.

These ensure that:

  • All mutation tasks that would invalidate the style run together before the next repaint.
  • All measurement tasks that need a valid style will run as soon as possible after the next repaint.
  • If a mutation task is scheduled by another mutation task, it will run in the same batch.
  • If a measurement task is scheduled by either a mutation or another measurement task, it will run in the same batch.
waitForMeasureTime
waitForMutateTime
waitForSubsequentMeasureTime
waitForSubsequentMutateTime

DOM: Querying

getVisibleContentChildren
isDOMElement
isInlineTag
isVisibleContentTag

DOM: Searching for reference elements

The functions allow you to find elements that match a given string specification.

getReferenceElement
waitForReferenceElement

Directions

getMaxDeltaDirection
getOppositeDirection
getOppositeXYDirections
getVectorDirection

Events: Generic

addEventListenerTo
callEventListener
removeEventListenerFrom

Gestures

GestureFragment
TouchDiff
getKeyGestureFragment
getPointerGestureFragment
getTouchDiff
getTouchGestureFragment
getWheelGestureFragment

Layout

getOtherAspectRatios
getOtherDevices

Logging

logError
logInfo
logWarn

Math

areAntiParallel
areParallel
degToRad
distanceBetween
easeInOutQuad
getBitmask
hAngle
havingMaxAbs
havingMinAbs
keyWithMaxVal
keyWithMinVal
maxAbs
minAbs
normalizeAngle
quadraticRoots
radToDeg
roundNumTo
sortedKeysByVal
toInt
toNonNegNum
toNum
toNumWithBounds
toPosNum

Overlays

OverlayOptions
createOverlay
getOverlay

Scrolling

ScrollToOptions
ScrollAction
getClosestScrollable
getCurrentScrollAction
isScrollable
scrollTo

Size measurements

getEntryBorderBox
getEntryContentBox

Tasks

Scheduler
SchedulerPostTaskOptions
TaskPriority
getDebouncedHandler
scheduleHighPriorityTask
waitForDelay

Text

camelToKebabCase
formatAsString
joinAsString
kebabToCamelCase
randId
splitOn
toMargins

Validation

isValidAspectRatio
isValidAspectRatioList
isValidBox
isValidDevice
isValidDeviceList
isValidDimension
isValidDirection
isValidDirectionList
isValidInputDevice
isValidInputDeviceList
isValidIntent
isValidIntentList
isValidMutationCategory
isValidMutationCategoryList
isValidNum
isValidPointerAction
isValidPointerActionList
isValidPosition
isValidScrollDirection
isValidScrollDirectionList
isValidScrollOffset
isValidStrList
isValidTwoFoldPosition
isValidView
isValidViewList
isValidXYDirection
isValidZDirection
validateBoolean
validateBooleanOrString
validateNumber
validateNumList
validateString
validateStringRequired
validateStrList

Views

getOppositeViews