use-gesture icon indicating copy to clipboard operation
use-gesture copied to clipboard

Reset pinch offset, change pinch sensitivity and change unpinching behaviour

Open ElectricPulse opened this issue 8 months ago • 0 comments

Discussed in https://github.com/pmndrs/use-gesture/discussions/669

Originally posted by ElectricPulse June 18, 2024 I am working on a custom html canvas library. I wanted to use react-use-gesture for the zooming, dragging on the canvas.

For zooming I used the usePinch hook which crucially provides event.origin (which useWheel doesn't). usePinch with a wheel needs to know the actual offset and spins off to crazy numbers if improper scaleBounds are set. Letting usePinch control the offset state causes a couple implementation issues.

  1. I need a reset view button -> I need to be able to reset pinch offset.
  2. I need to change the sensitivity of the pinch (this can't be done in the handler)
  3. I also don't want the behaviour where zoom is reset upon the first unpinch when zoomed in.

ElectricPulse avatar Jun 20 '24 05:06 ElectricPulse