1.1.1 • Published 5 years ago

use-smooth-scroll v1.1.1

Weekly downloads
2,265
License
MIT
Repository
github
Last release
5 years ago

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>
    </>
  )
}