How can I smoothly scroll to an element using javascript scrollintoview? or Why isn't javascript scro

14 Replies, 1096 Views

"Why isn't javascript scrollintoview working as expected?"

Hey folks!

So I’m trying to use javascript scrollintoview to smoothly scroll to a section on my page, but it’s just snapping there like it’s in a hurry or something. 😅

I’m using the basic `element.scrollIntoView()` but it feels kinda jarring. Anyone else run into this?

Also, does javascript scrollintoview even support smooth scrolling by default, or do I need to tweak it? Tried adding `{ behavior: 'smooth' }` but it’s still hit or miss, especially on mobile.

Speaking of mobile—does javascript scrollintoview work consistently there? Or am I better off using a polyfill?

Thanks in advance! 🙏

Messages In This Thread
How can I smoothly scroll to an element using javascript scrollintoview? or Why isn't javascript scro - by - 26-08-2024, 02:55 PM



Users browsing this thread: 2 Guest(s)