retyui / react-quick-pinch-zoom

A react component that providing multi-touch gestures for zooming and dragging on any DOM element.
https://react-quick-pinch-zoom.netlify.app/
308 stars 46 forks source link

how could zoom in / zoom out when #35

Closed caltamiranob closed 1 year ago

caltamiranob commented 3 years ago

@Hello, could you help me with this functionality:

When user press double tap my image scale to 2, next if the user press double tap again then my image scale to 1. There are some event o method to manage these funcionality.

I appreciate your support. Thank you

8eecf0d2 commented 3 years ago

I'm looking for the same thing - zoom in and out with a double tap.

I tried to do this with the scaleTo method but calling it from the onDoubleTap event breaks the animation logic - the updates are called but they all have a scale of 2 until the last update which has a scale of 1, this felt unresponsive and jerky.

In the end I found a hacky solution by tracking the current scale, setting enabled to false if the scale is max, listen for double tap / click events yourself on nested element and call scaleTo when triggered to zoom out - it works quite well.

ummahusla commented 2 years ago

In the end I found a hacky solution by tracking the current scale, setting enabled to false if the scale is max, listen for double tap / click events yourself on nested element and call scaleTo when triggered to zoom out - it works quite well.

@8eecf0d2 hey, would you mind sharing the code-snippet for it? I'm currently battling the same issue.

retyui commented 1 year ago

you can try alternative library: https://github.com/prc5/react-zoom-pan-pinch