Static
getRetrieve an existing widget by element and ID.
Static
registerIf no actions are supplied, nothing is done.
Optional
config: ScrollTriggerConfigLisnUsageError If the config is invalid.
Readonly
destroyUndoes all modifications to the element and returns it to its original state.
You will need to recreate it if you want to enable its functionality again.
Readonly
disableDisables the functionality of the widget. What this means is specific to each widget.
Readonly
enableRe-enables the functionality of the widget. What this means is specific to each widget.
Readonly
getReturns the trigger's actions.
Readonly
getReturns the trigger config.
Readonly
getReturns the element passed to the widget constructor.
Readonly
isReturns true if the widget is destroyed.
Readonly
isReturns true if the widget is currently disabled.
Readonly
onThe given handler will be called when the widget is destroyed.
Readonly
onThe given handler will be called when the widget is disabled.
Readonly
onThe given handler will be called when the widget is enabled.
Readonly
reverse"Undo"es all the Actions linked to the trigger.
Readonly
run"Do"es all the Actions linked to the trigger.
Readonly
toggle"Toggle"s all the Actions linked to the trigger.
Readonly
toggleRe-enables the widget if disabled, otherwise disables it.
ScrollTrigger allows you to run actions when the user scrolls a target element (or the main scrollable element) in a given direction, and undo those actions when they scroll in the opposite direction.
To use with auto-widgets (HTML API), see registerTrigger for the specification.
scrollable
: A string element specification. See getReferenceElement.threshold
: A number.Example
Show the element when the user scrolls the page up, hide when scrolling down. User scrolling left or right not trigger the action. See getOppositeXYDirections:
Example
As above, but using a CSS class instead of data attribute:
Example
Show the element 1000ms after the first time the user scrolls the page up:
Example
Add class
scrolled
the first time the user scrolls the page in any direction (note that theonce
option is implied here), and show the element 1000ms after each time the user scrolls the page up, hide it as soon as they scroll down:Example
When the user scrolls up or down the closest ancestor with class
section
, then add classesc1
andc2
and enable triggermy-trigger
defined on this same element; undo all of that when scrolling right or left:Example
As above, but using
data-lisn-ref
attribute instead of class selector.