Gathering detailed insights and metrics for scroll-into-view
Gathering detailed insights and metrics for scroll-into-view
Gathering detailed insights and metrics for scroll-into-view
Gathering detailed insights and metrics for scroll-into-view
compute-scroll-into-view
The engine that powers scroll-into-view-if-needed
scroll-into-view-if-needed
Ponyfill for upcoming Element.scrollIntoView() APIs like scrollMode: if-needed, behavior: smooth and block: center
dom-scroll-into-view
scroll dom node into view automatically
smooth-scroll-into-view-if-needed
Ponyfill for smooth scrolling elements into view (if needed!)
npm install scroll-into-view
Typescript
Module System
Node Version
NPM Version
99.5
Supply Chain
99.5
Quality
75.9
Maintenance
100
Vulnerability
100
License
JavaScript (99.66%)
HTML (0.34%)
Total Downloads
18,519,447
Last Day
2,425
Last Week
68,280
Last Month
307,835
Last Year
3,440,601
MIT License
351 Stars
193 Commits
57 Forks
8 Watchers
3 Branches
17 Contributors
Updated on Jun 19, 2025
Minified
Minified + Gzipped
Latest Version
1.16.2
Package Id
scroll-into-view@1.16.2
Unpacked Size
21.53 kB
Size
6.83 kB
File Count
6
NPM Version
8.5.0
Node Version
16.14.2
Cumulative downloads
Total Downloads
Last Day
-8.2%
2,425
Compared to previous day
Last Week
-11.9%
68,280
Compared to previous week
Last Month
6.6%
307,835
Compared to previous month
Last Year
0.9%
3,440,601
Compared to previous year
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
require it
1var scrollIntoView = require('scroll-into-view');
use it
1scrollIntoView(someElement);
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.
1scrollIntoView(someElement, { 2 3 time: 500, // half a second 4 5 6 ease: function(value){ 7 return Math.pow(value,2) - value; // Do something weird. 8 }, 9 10 validTarget: function(target, parentsScrolled){ 11 12 // Only scroll the first two elements that don't have the class "dontScroll" 13 // Element.matches is not supported in IE11, consider using Element.prototype.msMatchesSelector if you need to support that browser 14 15 return parentsScrolled < 2 && target !== window && !target.matches('.dontScroll'); 16 }, 17 18 align:{ 19 top: 0 to 1, default 0.5 (center) 20 left: 0 to 1, default 0.5 (center) 21 topOffset: pixels to offset top alignment 22 leftOffset: pixels to offset left alignment, 23 lockX: boolean to prevent X scrolling, 24 lockY: boolean to prevent Y scrolling 25 }, 26 27 isScrollable: function(target, defaultIsScrollable){ 28 29 // By default scroll-into-view will only attempt to scroll elements that have overflow not set to `"hidden"` and who's scroll width/height is larger than their client height. 30 // You can override this check by passing an `isScrollable` function to settings: 31 32 return defaultIsScrollable(target) || target !== window && ~target.className.indexOf('scrollable'); 33 }, 34 35 isWindow: function(target){ 36 // If you need special detection of the window object for some reason, you can do it here. 37 return target.self === target; 38 }, 39 40 cancellable: true, // default is true, set to false to prevent users from cancelling the scroll with a touch or mousewheel 41 42 maxSynchronousAlignments: 3, // default is 3. Maximum number of times to try and align elements synchronously before completing. 43 44 debug: true // default is false. This will spit out some logs that can help you understand what scroll-into-view is doing if it isn't doing what you expect. 45});
You can pass a callback that will be called when all scrolling has been completed or canceled.
1scrollIntoView(someElement [, settings], function(type){ 2 // Scrolling done. 3 // type will be 'complete' if the scroll completed or 'canceled' if the current scroll was canceled by a new scroll 4});
You can cancel the current scroll by using the cancel function returned by scrollIntoView:
1var cancel = scrollIntoView(someElement); 2 3// ... later ... 4 5cancel()
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 scrollIntoView.min.js
<script src="scrollIntoView.min.js"></script>
<script>
window.scrollIntoView(someElement);
</script>
All evergreen browsers are supported.
Yes this means IE11 is not supported, scroll-into-view has the same support targets as microsoft: https://www.zdnet.com/article/microsoft-sets-deadline-for-end-of-support-of-ie-11-by-365-apps/
This project exists thanks to all the people who contribute.
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]
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 1/15 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More