Exploring Alternative Emulators for React Native Development
January 20, 2024
1 min
setGestureState
Boolean
false
. true
onPanBegin({ originX, originY })
Function
onPan({ absoluteChangeX, absoluteChangeY, changeX, changeY })
Function
onPanEnd()
Function
panDecoratorStyle
Object
resetPan
Boolean
true
is passed, it will reset the state of the panning decorator. This can be useful if you want to reset the absolute change values, since these stay stored until you reset them.setGestureState
Boolean
false
.horizontal
Boolean
false
vertical
Boolean
false
left
Boolean
false
right
Boolean
false
up
Boolean
false
up
Boolean
false
continuous
Boolean
true
, then you will receive an update each time the touch moves. If false
you will only receive a single notification about the touch. true
initialVelocityThreshold
Number
0.7
verticalThreshold
Number
10
horizontalThreshold
Number
10
onSwipeBegin({ direction, distance, velocity })
Function
onSwipe({ direction, distance, velocity })
Function
continuous
is true
.onSwipeEnd({ direction })
Function
swipeDecoratorStyle
Object
npm i react-native-gesture-recognizers
import React, { useRef, useState } from 'react'; import { View, Image, StyleSheet } from 'react-native'; import { PinchGestureHandler } from 'react-native-gesture-handler'; export default function App() { const pinchRef = useRef(null); const imageRef = useRef(null); const [scale, setScale] = useState(1); const onPinchGestureEvent = ({ nativeEvent }) => { setScale(nativeEvent.scale); imageRef.current.setNativeProps({ style: { transform: [{ scale: nativeEvent.scale }], }, }); }; return ( <View style={styles.container}> <PinchGestureHandler ref={pinchRef} onGestureEvent={onPinchGestureEvent} onHandlerStateChange={({ nativeEvent }) => { if (nativeEvent.oldState === 4) { setScale(1); imageRef.current.setNativeProps({ style: { transform: [{ scale: 1 }], }, }); } }} > <Image ref={imageRef} source={{ uri: 'https://media-cldnry.s-nbcnews.com/image/upload/t_fit-560w,f_auto,q_auto:best/rockcms/2022-01/210602-doge-meme-nft-mb-1715-8afb7e.jpg' }} style={{ width: 200, height: 200, transform: [{ scale: scale }] }} /> </PinchGestureHandler> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, });
Coming Soon…
Quick Links
Legal Stuff