uds

use-draggable-scroll

React hook to add draggability to scrollable content easily

Showing:

Popularity

Downloads/wk

144

GitHub Stars

10

Maintenance

Last Commit

2mos ago

Contributors

3

Package

Dependencies

0

License

MIT

Type Definitions

Built-In

Tree-Shakeable

Yes?

Categories

Readme

use-draggable-scroll

React hook to add draggability to scrollable content easily.

Installation

yarn add use-draggable-scroll

or

npm install use-draggable-scroll

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' });

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100