Search...
onViewportEnter( )
Adds an event handler that runs when an element is displayed in the viewable part of the current window.
Description
An element enters the viewport when the page is scrolled to show any
part of the element. An element also enters the viewport if it was
hidden or collapsed
and is then shown or expanded in the viewable part of the current window. onViewportEnter()
is not fired for hidden or collapsed
elements even if they are scrolled into view.
You can also define an event handler using the Properties and Events panel.
Syntax
function onViewportEnter(handler: EventHandler): Elementhandler: function EventHandler(event: Event): void
onViewportEnter Parameters
NAME
TYPE
DESCRIPTION
handler
The name of the function or the function expression to run when the element enters the viewport.
EventHandler Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
void
Mixed in from:$w.Element
Related Content:
Was this helpful?
Get the ID of the element that has entered the viewport
Copy Code
1$w("#myElement").onViewportEnter( (event) => {2 let targetId = event.target.id; // "myElement"3});