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

14 Replies, 1139 Views

Ugh, I feel your pain! javascript scrollintoview is great... when it works. The smooth scrolling issue is usually browser-related.

Pro tip: Wrap it in a `setTimeout` or use `requestAnimationFrame` to force it. Like:

```js
setTimeout(() => {
element.scrollIntoView({ behavior: 'smooth' });
}, 100);
```

Mobile is a wild west tho. Maybe try `scrollTo` with manual easing?

Messages In This Thread



Users browsing this thread: 1 Guest(s)