magic-akari/seamless-scroll-polyfill

Detect after scroll finish

Closed this issue · 1 comments

Hello, thanks for this amazing package.

Is there any way to detect when scroll finished ?

elementScrollIntoView('#element', {
 behavior: 'smooth',
 block: 'center',
}).then(() => {
 // Do something
});

Hi,
The scrollIntoView should return undefined according the spec.


When a user agent is to perform a smooth scroll of a scrolling box box to position, it must update the scroll position of box in a user-agent-defined fashion over a user-agent-defined amount of time. When the scroll is completed, the scroll position of box must be position. The scroll can also be aborted, either by an algorithm or by the user.

You can pass in a third parameter to set the duration.
However, it should be noted that after such a time, the page may not be in the destination position, as scrolling can be aborted by the user.