Hacker News new | ask | show | jobs
by ska-dev 876 days 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.
2 comments

Thank 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.
Native smooth-scrolling is one area where Safari is actually really good and Chrome is bizarrely awful.
Won’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.
Nope!

    Element.scrollIntoView({ behavior: 'smooth' });
https://developer.mozilla.org/en-US/docs/Web/API/Element/scr...