DuDigital / 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
243 stars 113 forks source link

How to reset zoom value. #21

Closed usmankhan495 closed 5 years ago

usmankhan495 commented 5 years ago

Hi I was to reset the zoom level.The use case for which I am trying to do is If the view is already zoomed In and then user double tab the view it should reset to initial zoom level but is is not working as expected.Can you please suggest any solution.

<ReactNativeZoomableView
   maxZoom={1.5}
   minZoom={1}
   zoomStep={0.5}
   zoomEnabled={this.state.isEnabledZoom}
   initialZoom={this.state.initialZoom}
   bindToBorders={true}
 onDoubleTapAfter={(event, gestureState, zoomableViewEventObject)=>{

    if(this.state.initialZoom>1){
     this.setState({ initialZoom: 1,isEnabledZoom:false, scroll:true })
     }else{
     this.setState({ initialZoom:zoomableViewEventObject.zoomLevel,isEnabledZoom:true })
     }/>

This is what I am currently doing. Thanks

galzate-blumer commented 4 years ago

Why you close it? Did you solve it?

usmankhan495 commented 4 years ago

@galzate-blumer , Yes check this answer: https://github.com/DuDigital/react-native-zoomable-view/issues/14#issuecomment-503630928