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

20 Replies, 1511 Views

If js scroll into view isn’t smooth, it might be a rendering issue. Try forcing a reflow before scrolling:

```js
const el = document.getElementById('myElement');
el.offsetHeight; // force reflow
el.scrollIntoView({ behavior: 'smooth' });
```

Weird hack, but it works more often than not.

Messages In This Thread



Users browsing this thread: 1 Guest(s)