use-gesture
use-gesture copied to clipboard
Reset pinch offset, change pinch sensitivity and change unpinching behaviour
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.
- I need a reset view button -> I need to be able to reset pinch offset.
- I need to change the sensitivity of the pinch (this can't be done in the handler)
- I also don't want the behaviour where zoom is reset upon the first unpinch when zoomed in.