Gathering detailed insights and metrics for react-smooth-scroll-hook
Gathering detailed insights and metrics for react-smooth-scroll-hook
Gathering detailed insights and metrics for react-smooth-scroll-hook
Gathering detailed insights and metrics for react-smooth-scroll-hook
react-smooth-scroller-hook
Simple React hook for Smooth Scrolling Effect
use-smooth-horizontal-scroll
This package provides a custom hook for smooth horizontal scrolling in React. The hook allows for setting a scroll container, handling scroll events, scrolling to a specific point, and determining if the user is at the start or end of the scrollable area.
next-use-smooth-scroll
A simple smooth scroll react hook for Next.js
use-smooth-scroll
React hook which gives a smooth scrolling function.
A React Hook for using smooth scroll in React Component
npm install react-smooth-scroll-hook
Typescript
Module System
Min. Node Version
Node Version
NPM Version
71.4
Supply Chain
93.5
Quality
75.6
Maintenance
100
Vulnerability
100
License
TypeScript (93.08%)
JavaScript (5.58%)
HTML (1.23%)
CSS (0.1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
114 Stars
84 Commits
5 Forks
3 Watchers
3 Branches
2 Contributors
Updated on Jul 02, 2025
Latest Version
1.3.4
Package Id
react-smooth-scroll-hook@1.3.4
Unpacked Size
107.11 kB
Size
21.54 kB
File Count
19
NPM Version
6.14.8
Node Version
12.19.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
34
The useSmoothScroll
hook finish smooth scroll behaviour in react component by requestAnimationFrame
.
Storybook Docs are Here.
🚀 You don't need to warn about compatibility, it use requsetAnimationFrame
api to finish smooth scroll behaviour.
👉 Provide direction
option ,you can set x
for horizontal, y
for vertical.
💧 No Third Party dependencies, light and pure.
1npm install react-smooth-scroll-hook
1import React, { useRef } from 'react'; 2import useSmoothScroll from 'react-smooth-scroll-hook'; 3export const Demo = () => { 4 // A custom scroll container 5 const ref = useRef(null); 6 7 // Also support document.body / document.documentElement, and you don't need to set a ref passing to jsx 8 const ref = useRef(document.body); 9 10 const { scrollTo } = useSmoothScroll({ 11 ref, 12 speed: 100, 13 direction: 'y', 14 }); 15 16 return ( 17 <> 18 <button onClick={() => scrollTo('#item-20')}>scrollTo('#item-20')</button> 19 <div 20 // if use custom scroll container, pass ref 21 ref={ref} 22 style={{ 23 overflowY: 'scroll', 24 maxHeight: '200px', 25 }} 26 > 27 {Array(100) 28 .fill(null) 29 .map((_item, i) => ( 30 <div key={i} id={`item-${i}`}> 31 item-{i} 32 </div> 33 ))} 34 </div> 35 </> 36 ); 37};
RefObject<HTMLElement>
, container which set as overflow: scroll
, if scroll whole document, pass ref = useRef(document.documentElement)
or useRef(document.body)
.requestAnimationFrame
mode, defaults to 100
, if not provide, speed depends on native API scrollTo
.x
for horizontal or y
for vertical.1
.scrollTo (string|number) => void
number
: the distance to scroll, e.g. scrollTo(400)
string
: the element seletor you want to scrollTo, meanwhile passing to document.querySelector
, e.g. scrollTo('#your-dom-id')
reachedTop boolean
: Whether it has reached the top of refContainer
reachedBottom boolean
: Whether it has reached the bottom of refContainer
scrollToPage (number) => void
: Pass page(number
), which scroll to a distance as multiples of container size(offsetWidth
/offsetHeight
)
.e.g scrollToPage(1)
,scrollToPage(-1)
refreshState () => void
: Manually refresh the state of reachTop
and reachBottom
, possibly useful in some situation.
refreshSize () => void
: Manually refresh the size of ref container, possibly useful in some situation.
Proviede a list
of dom like below, and pass the parent container ref
to hook, it return the scrollbar current state of scrollTop
, curIndex
, curItem
.
1import React, { useRef } from 'react'; 2import { useScrollWatch } from 'react-smooth-scroll-hook'; 3export const ScrollConatainerMode = () => { 4 const ref = useRef(null); 5 const { scrollTop, curIndex, curItem } = useScrollWatch({ 6 ref, 7 list: [ 8 { 9 href: '#item-0', 10 }, 11 { 12 href: '#item-10', 13 }, 14 { 15 href: '#item-20', 16 }, 17 ], 18 }); 19 return ( 20 <> 21 <h2>Scroll Container Mode</h2> 22 <div> 23 <p> 24 <strong>scrollTop:</strong> {scrollTop} 25 </p> 26 <p> 27 <strong>curIndex:</strong> {curIndex} 28 </p> 29 <p> 30 <strong>curHref:</strong> {curItem?.href} 31 </p> 32 </div> 33 <div 34 style={{ 35 padding: '10px', 36 maxHeight: '200px', 37 overflowY: 'scroll', 38 }} 39 ref={ref} 40 > 41 {Array(100) 42 .fill(null) 43 .map((_item, i) => ( 44 <div key={i} id={`item-${i}`}> 45 item-{i} 46 </div> 47 ))} 48 </div> 49 </> 50 ); 51};
Array({href, offset})
: href
is elemet selector string, which passing to querySelector
, such as #element-id
useSmoothScroll
number
: current scrollTop of scroll container.number
: current Index of list{href, offset}
: current Item of listNo vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 0/24 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
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
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
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
132 existing vulnerabilities detected
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