Static
getRetrieve an existing widget by element and ID.
Static
registerIf no actions are supplied, nothing is done.
Optional
config: ViewTriggerConfigLisnUsageError 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.
ViewTrigger allows you to run actions when the viewport's scroll position relative to a given target or offset from top/bottom/left/right is one of the matching "views" (at/above/below/left/right), and undo those actions when the viewport's "view" is not matching.
To use with auto-widgets (HTML API), see registerTrigger for the specification.
target
: A string element specification for an element (see getReferenceElement) or a ScrollOffset.root
: A string element specification. See getReferenceElement.rootMargin
: A string.threshold
: A number or list (comma-separated) of numbers.Example
Show the element when it's in the viewport, hide otherwise.
Example
Same as above. "views" is optional and defaults to "at".
Example
As above but using a CSS class instead of data attribute:
Example
Show the element 1000ms after the first time it enters the viewport.
Example
Add class
seen
the first time the element enters the viewport, and play the animations defined on it 1000ms after each time it enters the viewport, reverse the animations as soon as it goes out of view.Example
Add class
seen
when the viewport is at or below the element (element above viewport), remove it when the viewport is above the element. Element going to the left or right of the viewport will not trigger the action. See getOppositeViews:Example
Add class
cls
when the viewport is above or to the left the element (element below or to the right of the viewport), remove it when the viewport is either at, below or to the right of the element.Example
Hide the element when the viewport is above the next element with class
section
, show it when the viewport is below or at the target element.Example
As above, but using
data-lisn-ref
attribute instead of class selector.Example
Open the Openable widget configured for this element when the viewport is 75% down from the top of the page.