Scrolls an element into view
Also scrolls any scroll-parents so that the element is in view.
If you want to show your support financially, I'm on Patreon
var scrollIntoView = ;
You can pass settings to control the time, easing, and whether or not a parent is a valid element to scroll, and alignment:
All options are optional.
You can pass a callback that will be called when all scrolling has been completed or canceled.
You can cancel the current scroll by using the cancel function returned by scrollIntoView:
var cancel = ;// ... later ...
Small. ~3.03 KB for the standalone.
Testing scrolling is really hard without stuff like webdriver, but what's there works ok for the moment.
The tests will attempt to launch google-chrome. If you don't have chrome, lol just kidding you do.
npm run test
If you want to use this module without browserify, you can use
<script src="scrollIntoView.min.js"></script> <script> window.scrollIntoView(someElement); </script>
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]