useDrag
A pair of hooks to help you manage data transfer between drag and drop
Overview
A pair of hooks to help you manage data transfer between drag and drop
Installation
Open inpnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDrag.jsonnpx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDrag.jsonyarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDrag.jsonbun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useDrag.jsonBasic Usage
Customize Image
API
useDrag
useDrag<T>(
data: any,
target: (() => Element) | Element | MutableRefObject<Element>,
options?: DragOptions
);Params
| Property | Description | Type | Default |
|---|---|---|---|
| data | Drag data | any | - |
| target | DOM element or ref | () => Element | Element | MutableRefObject<Element> | - |
| options | More config | DragOptions | - |
DragOptions
| Property | Description | Type | Default |
|---|---|---|---|
| onDragStart | On drag start callback | (e: React.DragEvent) => void | - |
| onDragEnd | On drag end callback | (e: React.DragEvent) => void | - |
| dragImage | Customize image that follow the mouse pointer during dragging | DragImageOptions | - |