What is the best way to detect when scrolling to an element on the page has finished? The spec says that "The scrolling box is scrolled in a smooth fashion using a user-agent-defined timing function over a user-agent-defined period of time. User agents should follow platform conventions, if any."
(2017-11-23) On a related note, Firefox 58 now has a chrome-only scrollend
event.
Anyway, to disable smooth scrolling in Chrome, follow these steps: Step 1: Type in chrome://flags/#smooth-scrolling in Chrome's address bar and press Enter. Step 2: To turn the feature off, click on the disable link. Then, click on a restart button to complete the process.
Definition and Usage The scroll-behavior property specifies whether to smoothly animate the scroll position, instead of a straight jump, when the user clicks on a link within a scrollable box.
Safari 15.4 adds support for CSS scroll-behavior as detailed in the 15.4 release notes. Added support for the CSS scroll-behavior property and ScrollOptions, allowing smooth scrolling to anchors or via JavaScript. I've tested and it works on 15.4 (Safari Technology Preview).
To scroll to an element, just set the y-position to element. offsetTop . The SmoothScroll.
The only feasible option appears to be to just wait until there aren't any more scroll
events:
let timer; window.addEventListener( 'scroll', () => { clearTimeout( timer ); timer = setTimeout( () => { callback(); }, 300 ); }, { passive: true } );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With