import React from 'react'
import {View,Image,Animated, Button} from 'react-native'
import {PinchGestureHandler} from 'react-native-gesture-handler'
export default function pinchZoom(){
const scale=React.useRef(new Animated.Value(1)).current;
const HandlePinch=new Animated.event(
[{nativeEvent:{scale:scale}}]
,
{
useNativeDriver: false
})
const anime=new Animated.ValueXY(0,0)
return(
<View style={{flex:1}}>
<PinchGestureHandler onGestureEvent={HandlePinch}>
<Animated.Image source={{uri:'https://i.ytimg.com/vi/Z4ls0-ZGnU4/maxresdefault.jpg'}}
style={{height:250,width:'100%',transform:[{scale:scale}]}}
/>
</PinchGestureHandler>
</View>
)
}
i have an android device, and it is not working, dont know why please help!!!!! beside this PanGestureHandler working perfectly
Enclose the <PinchGestureHandler> with
<GestureHandlerRootView>
It should look like this:
<GestureHandlerRootView>
<PinchGestureHandler onGestureEvent={HandlePinch}>
<Animated.Image source={{uri:'https://i.ytimg.com/vi/Z4ls0-ZGnU4/maxresdefault.jpg'}}
style={{height:250,width:'100%',transform:[{scale:scale}]}}
/>
</PinchGestureHandler>
</GestureHandlerRootView>
And don't forget to import it from react-native-gesture-handler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With