Skip to content

mat-sz/react-use-pointer-drag

Repository files navigation

react-use-pointer-drag

workflow npm npm NPM

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 })} />;

About

🖱️ Simplified mouse/touch dragging hook.

Resources

License

Stars

Watchers

Forks

Packages

No packages published