Gathering detailed insights and metrics for use-ref-scroller
Gathering detailed insights and metrics for use-ref-scroller
Gathering detailed insights and metrics for use-ref-scroller
Gathering detailed insights and metrics for use-ref-scroller
npm install use-ref-scroller
Typescript
Module System
Node Version
NPM Version
68.6
Supply Chain
87.4
Quality
75.2
Maintenance
100
Vulnerability
80.9
License
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
GPL-3.0 License
4 Stars
13 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Mar 08, 2023
Latest Version
1.0.0
Package Id
use-ref-scroller@1.0.0
Unpacked Size
45.70 kB
Size
15.62 kB
File Count
13
NPM Version
6.13.6
Node Version
13.7.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
A react hook for scrolling to DOM elements
Only 599 bytes minified + g-zipped
You have a component which renders a DOM element you wish to be able to scroll to and you need a scrolling function to call
1import React from 'react'; 2 3import useRefScroller from 'use-ref-scroller'; 4 5function MyComponent() { 6 // using the hook without arguments will scroll the element to the center of the 7 // window's viewport 8 // alias elRef to myDiv for easier usage if having multiple elements 9 // in the same component 10 11 const { elRef: myDiv, scroll } = useRefScroller(); 12 13 return ( 14 <div> 15 <button onClick={scroll}>Scroll</button> 16 17 <div ref={myDiv}> 18 `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum efficitur, massa vitae consectetur egestas, justo magna 19 facilisis arcu, non accumsan lacus ipsum sit amet nisl.` 20 </div> 21 </div> 22 ); 23}
1interface ScrollOpts { 2 // Offset in percentage of the element's client dimentions 3 // default is to scroll to center the element in the scrolling pane, hence 50% 4 percentOfElement?: number; 5 //The offset in pixels, whch will be added to the percentage of the element 6 offsetPX?: number; 7 // Whether to run the scroll on mounting 8 onMount?: boolean; 9 // The scrollable container in which the ref element is scrolling 10 container?: any; 11 // default is the center of the scrolling container, hence 50% 12 percentOfContainer?: number; 13 // ScrollDirections.Vertical is the default setting, pass ScrollDirections.Horizontal to override it 14 direction?: ScrollDirections; 15}
1// scroll the element to the beginning of the screen horizontally 2const { elRef, scroll } = useRefScroller({ percentOfElement: 0, percentOfContainer: 0 }); 3 4// scroll the center of the element to the center of the screen 5const { elRef, scroll } = useRefScroller(); 6 7// scroll the element 200px from the bottom 8const { elRef, scroll } = useRefScroller({ offsetPx: -200, percentOfContainer: 100 });
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/13 approved changesets -- 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
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
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