react-native-image-zoom
react-native-image-zoom copied to clipboard
How to get if My image is back on scale factor 1
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!!!!
You can add a listener onScaleChange, welcome pr!
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>
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