use-draggable-scroll
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

use-draggable-scroll

React hook to add draggability to scrollable content easily.

Usage

import { useDraggableScroll } from 'use-draggable-scroll';

const Component = () => {
  const ref = useRef(null);

  const { onMouseDown } = useDraggableScroll(ref);

  return (
    <div ref={ref} onMouseDown={onMouseDown}>
      <div>child 1</div>
      <div>child 2</div>
      <div>child 3</div>
    </div>
  );
};

Optional parameters

You can specify the drag direction that is allowed (vertical, horizontal or both(default))

const { onMouseDown } = useDraggableScroll(ref, { direction: 'vertical' });

Package Sidebar

Install

npm i use-draggable-scroll

Weekly Downloads

7,638

Version

0.1.0

License

MIT

Unpacked Size

24.6 kB

Total Files

12

Last publish

Collaborators

  • g-delmo