mnogueron / react-easy-panzoom

Wrapper to enable pan and zoom features for any React component
MIT License
79 stars 17 forks source link

Reset zoom on end #29

Open brunoxd13 opened 5 years ago

brunoxd13 commented 5 years ago

I would like to zoom only when I have the pinch motion and after that I would like to zoom out. Like in Instagram.

I tried using the onPanEnd method and there I usedzoomTo (0, 0, 0)and alsoreset ()

How could I solve this?

Reset zoom when done

<PanZoom autoCenter ref={panZoom} 
    onPanEnd={() => {
        console.log(panZoom);
        panZoom.current.zoomTo(0, 0, 0);
        panZoom.current.reset(); 
    }}
>
     <img src={image.url} alt="imagem slider" />
</PanZoom>
mnogueron commented 5 years ago

Hi @brunoxd13 and thank you for the issue. I have added a new demo story for an Instagram-like pinch to zoom that you can check. This one is simply using the reset function to reset the zoom and pan to the original position. This story should only be considered on a mobile as the pinch to zoom is not yet supported on desktop. You will notice that the pan (without zoom) is still enabled but will automatically reset to the origin. There is not yet any option to disable the pan without disabling the zoom feature, this should come as a future update.