Draggable Scrollable Library For React

A React hook that adds draggable functionality to scrollable content.

How to use it:

1. Import and register the hook.

# Yarn
$ yarn add use-draggable-scroll

$ npm i use-draggable-scroll --save
import { useDraggableScroll } from 'use-draggable-scroll';

2. Basic usage.

const Component = () => {
  const ref = useRef(null);
  const { onMouseDown } = useDraggableScroll(ref);
  return (
    <div ref={ref} onMouseDown={onMouseDown}>
      <div>Item 1</div>
      <div>Item 2</div>
      <div>Item 3</div>

3. Set the drag direction that is allowed: vertical, horizontal or both (default).

const { onMouseDown } = useDraggableScroll(ref, { 
  direction: 'horizontal' 


Draggable Scrollable Library For React

Download Details:

Author: g-delmo

Live Demo: View The Demo

Download Link: Download The Source Code

Official Website: https://github.com/g-delmo/use-draggable-scroll

License: MIT


Add Comment