DEV Community

Cover image for ( 'scrollend' ) A New JS Event
Murtaza Joo
Murtaza Joo

Posted on • Updated on

 

( 'scrollend' ) A New JS Event

scrollend is a new javascript events just like any other event (click,scroll etc).

when is it fired?

the scrollend event is same as the other events, and the syntax is same as other events.

The scrollend event fires when element scrolling has completed. Scrolling is considered completed when the scroll position has no more pending updates and the user has completed their gesture. or in other words

when the scroll event ends

Demo Video

I could have embed code-pen but the event is not supported by many bowsers

Syntax

element.addEventListener("scrollend", (event) => {
  output.innerHTML = "Scrollend event fired!";
});
Enter fullscreen mode Exit fullscreen mode

OR

element.onscrollend = (event) => {
  output.innerHTML = "Element scrollend event fired!";
};
Enter fullscreen mode Exit fullscreen mode

Browser compatibility

  • its a new event so only few Browsers supports this event.
Browser support version
Chrome canary dev
Firefox yes 109
Edge No --
Safari No --
Opera No --

Documentation

Chrome

mozilla

Can you think of any use?

Top comments (2)

Collapse
 
murtazajooo profile image
Murtaza Joo

one of many uses

  • Fetching data after a user scrolls to a new tab.
Collapse
 
murtazajooo profile image
Murtaza Joo

Safari - as always

Need a better mental model for async/await?

Check out this classic DEV post on the subject.

⭐️🎀 JavaScript Visualized: Promises & Async/Await

async await