react-use-pointer-drag A simple hook for handling drag and move actions in React apps.
Example usage
Simple:
// In component:
const { dragProps } = usePointerDrag({
onMove: ({ x, y }) => {
// Do something.
},
});
return <div {...dragProps()} />;
With state:
// In component:
const { dragProps } = usePointerDrag<{ clip: Clip }>({
onMove: ({ x, y, state: { clip } }) => {
// Do something.
},
});
return <div {...dragProps({ clip })} />;