useDrag

Drag an element with the pointer and read how far it moved.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

Drag the box, the position is kept between drags.

APIs

useDrag

const useDrag = <T extends HTMLElement = HTMLElement>() => {
  ref: RefObject<T | null>
  dragging: boolean
  position: { x: number; y: number }
  reset: () => void
}
Edit this page on GitHub