An open API service indexing awesome lists of open source software.

https://github.com/andarist/use-smooth-scroll

React hook which gives a smooth scrolling function.
https://github.com/andarist/use-smooth-scroll

hook hooks react reactjs scroll

Last synced: about 1 year ago
JSON representation

React hook which gives a smooth scrolling function.

Awesome Lists containing this project

README

          

# use-smooth-scroll

React hook which gives a smooth scrolling function.

## Example ([Codesandbox](https://codesandbox.io/s/github/Andarist/use-smooth-scroll/tree/master/examples/simple))

```js
const Example = () => {
const ref = React.useRef()
const scrollTo = useSmoothScroll('x', ref)

return (
<>
scrollTo(getRandomScrollTarget(ref.current))}>
Click me


{range(100).map(i => (

))}

>
)
}
```