onViewportLeave( )

Adds an event handler that runs when an element is no longer displayed in the viewable part of the current window.


An element leaves the viewport when the page is scrolled so that the element is completely out of view. An element also leaves the viewport if it was shown or expanded and is then hidden or collapsed from the viewable part of the current window. onViewportLeave() is not fired for hidden or collapsed elements even if they are scrolled out of view.

You can also define an event handler using the Properties and Events panel.



This endpoint does not take any parameters

Response Object

The element on which the event is now registered.

Returns an empty object.

Status/Error Codes

Related Content:

Was this helpful?

Get the ID of the element that has left the viewport

Copy Code
1$w("#myElement").onViewportLeave( (event) => {
2 let targetId =; // "myElement"