6 ms·
Yesterday I was reaching for the JS I have used in the past for smooth scrolling to anchor links, until I discovered that `scroll-behavior: smooth;` exists.
by ska-dev 3y ago
Yesterday I was reaching for the JS I have used in the past for smooth scrolling to anchor links, until I discovered that `scroll-behavior: smooth;` exists.
- lakpan 3y agoThank god. Most if not all “smooth scrolling” suck on devices that already offer smooth scrolling natively. I tried contributing solution back but they just didn’t care.
- asimpletune 3y agoNative smooth-scrolling is one area where Safari is actually really good and Chrome is bizarrely awful.
- lobsterthief 3y agoWon’t you still need some smooth-scrolling JS for cases where you’re scrolling to an element dynamically? Like when updating a route without a full page load or click.
- Vorh 3y agoNope! Element.scrollIntoView({ behavior: 'smooth' }); https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView https://developer.mozilla.org/en-US/docs/Web/API/Element/scr...