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

20 Replies, 1512 Views

Had this exact headache last week! js scroll into view can be glitchy if the DOM isn’t fully loaded when the script runs.

Try wrapping your code in:
```js
window.addEventListener('load', () => {
// your scroll code here
});
```

If that doesn’t help, maybe the element’s `offsetParent` is null? Check that too.

Messages In This Thread



Users browsing this thread: 1 Guest(s)