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.
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.
