Re:Modern CSS One-Line Upgrades
by ska-dev on Monday January 29, 2024 @04:11AM
(#39174303)
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.
[ Parent
| on HN ]
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.
Re:Modern CSS One-Line Upgrades
by asimpletune on Monday January 29, 2024 @08:20AM
(#39175887)
Native smooth-scrolling is one area where Safari is actually really good and Chrome is bizarrely awful.
Re:Modern CSS One-Line Upgrades
by lobsterthief on Monday January 29, 2024 @10:02AM
(#39177002)
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...