How to smoothly scroll an element into view using js scroll into view? or What's the best way to impl

20 Replies, 1519 Views

Honestly, I gave up on native js scroll into view for smooth scrolling. Now I just use `scrollTo` with a tiny delay:

```js
setTimeout(() => {
window.scrollTo({
top: document.getElementById('myElement').offsetTop,
behavior: 'smooth'
});
}, 100);
```

Not elegant, but hey, it’s consistent.

Messages In This Thread



Users browsing this thread: 1 Guest(s)