openspacelabs / react-native-zoomable-view

A view component for react-native with pinch to zoom, tap to move and double tap to zoom capability.
MIT License
191 stars 58 forks source link

Reset Zoom Level after State Refresh #26

Closed EricLi35 closed 2 years ago

EricLi35 commented 2 years ago

I am implementing a dropdown menu where the user can select one of three pictures. I was wondering how you can reset the zoom level upon selecting another picture. The issue is that if I zoom into a picture and select a different picture, the same zoom level is still there for the new picture. I have experimented with initialZoom already and that didn't seem to work.

Thanks in advance for any help/suggestions

elliottkember commented 2 years ago

@EricLi35 Have you tried setting a key on the component? Changing the key of a React component will cause it to re-mount. Re-mounting might do the trick!

EricLi35 commented 2 years ago

Hi, thanks for the reply. I ended up finding an alternate method by moving the ReactNativeZoomableView into a closer layer.

esadkrs commented 2 years ago

Hey @EricLi35 , can you please share your method?

thomasttvo commented 2 years ago

You can also use ref.zoomTo(1) https://github.com/openspacelabs/react-native-zoomable-view#methods