scrollIntoViewIfNeeded 4 everyone!!!
scrollIntoViewIfNeeded that can be called on DOM elements.
Just use the code in
index.js in your app or website. You can see usage in the test page
The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.
- This code doesn't handle well cases where the element has
position:absolute(and maybe other CSS modifications).
- This code doesn't handle cases where the scroll area isn't the direct parent of the target element.
If you have any ideas to improve this code or if you think the WebKit implementation doesn't work like this, feel free to start a discussion...
Hubert SABLONNIÈRE @hsablonniere