use-smooth-scroll

1.1.1 • Public • Published

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

/use-smooth-scroll/

    Package Sidebar

    Install

    npm i use-smooth-scroll

    Weekly Downloads

    1,977

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    8.28 kB

    Total Files

    5

    Last publish

    Collaborators

    • andarist