JSPM

use-draggable-scroll

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6215
  • Score
    100M100P100Q127650F
  • License MIT

React hook to add draggability to scrollable content easily

Package Exports

  • use-draggable-scroll

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (use-draggable-scroll) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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