Skip to Content
react-utilsuseDragScroll

useDragScroll

See source on Github 

Enables a scrollable ref to be scrolled using drag gestures generated by a traditional mouse.

  • @param ref - The element to attach the gesture to.
  • @param options - Configurable options
  • @param options.when - Whether drag scrolling is enabled.
  • @param options.axis - Axis to constrain scrolling to.
  • @param options.deadZone - Movement required before dragging starts.
  • @param options.onGestureStart - Called when dragging starts.
  • @param options.onGestureMove - Called as dragging moves.
  • @param options.onGestureEnd - Called when dragging ends.
  • @param options.inertia - Whether movement continues after release.
  • @returns void

Example

const ref = useRef<HTMLDivElement>(null) useDragScroll(ref); return <div ref={ref} />