react-native-image-zoom icon indicating copy to clipboard operation
react-native-image-zoom copied to clipboard

How to get if My image is back on scale factor 1

Open anshulsingh1991 opened this issue 7 years ago • 3 comments

As a user, If I double tap on image to scale it, by default I am getting result where image is scaled by 2. (scale : 2) Now if i want to get this value in code, using onMove I can see scale as 2. Here's the problem is - onMove will only fire if user moves image. If i keep on doing double tap on image, scale factor will be increasing to 2 and coming back to 1. This process will keep going, but there is no way (or unfortunately I am not able find) to get scale (scaling factor) in this scenario.

Purpose - I wanted to show / hide some section based on scale factor (If scale 1 - show, otherwise hide)

PS - I know onMove gives scale but it will only trigger if user moves image, keep on double tap on image does not trigger it, scenario mentioned above)

PLEASE HELP!!!!

anshulsingh1991 avatar Nov 05 '18 19:11 anshulsingh1991

You can add a listener onScaleChange, welcome pr!

ascoders avatar Nov 06 '18 02:11 ascoders

I hope you find it useful

<ImageZoom
  ref={ref => (this.ImageZoom = ref)}   //Here 
  cropWidth={Dimensions.get("window").width}
  cropHeight={this.state.height}
  imageWidth={Dimensions.get("window").width}
  imageHeight={this.state.height}
  pinchToZoom={true}
  responderRelease={() => {  //start
  this.ImageZoom.reset();   <===  HERE
   }}                     //end
   >
   <FastImage
     style={{
      flex: 1,
      height: this.state.height,
      width: WidthG
    }}
     source={{
      uri: this.state.image
    }}
    resizeMode={FastImage.resizeMode.contain}
   />
</ImageZoom>

DanthonyPabon avatar Feb 21 '19 21:02 DanthonyPabon

I hope you find it useful

<ImageZoom
  ref={ref => (this.ImageZoom = ref)}   //Here 
  cropWidth={Dimensions.get("window").width}
  cropHeight={this.state.height}
  imageWidth={Dimensions.get("window").width}
  imageHeight={this.state.height}
  pinchToZoom={true}
  responderRelease={() => {  //start
  this.ImageZoom.reset();   <===  HERE
   }}                     //end
   >
   <FastImage
     style={{
      flex: 1,
      height: this.state.height,
      width: WidthG
    }}
     source={{
      uri: this.state.image
    }}
    resizeMode={FastImage.resizeMode.contain}
   />
</ImageZoom>

How can use this only when we changed image ?

Case :

  • If we still on the same image, don't fire reset
  • If we change image (swipe left or right), fire reset On the previous image

?

Please

Steffi3rd avatar Jun 01 '19 21:06 Steffi3rd