use-smooth-scroll
v1.1.1
Published
React hook which gives a smooth scrolling function.
Downloads
13,695
Maintainers
Readme
use-smooth-scroll
React hook which gives a smooth scrolling function.
Example (Codesandbox)
const Example = () => {
const ref = React.useRef()
const scrollTo = useSmoothScroll('x', ref)
return (
<>
<button onClick={() => scrollTo(getRandomScrollTarget(ref.current))}>
Click me
</button>
<Carousel innerRef={ref}>
{range(100).map(i => (
<Card key={i} />
))}
</Carousel>
</>
)
}