Closed rizwan92 closed 1 year ago
any update?
If you want the gestures to work alongside the native views handling touch by themselves, you need to wrap them with GestureDetector
recognizing Native
gesture. You will also need to mark them as simultaneous. You also need to wrap your application with GestureHandlerRootView
, otherwise GH will not be able to intercept touch events.
it still has a lot of glitches it's not smooth, and scrolling horizontally was way too much pain in android
i dont know why this code has more better experience but not good for production
<GestureDetector gesture={pinchGesture}>
<View className="flex flex-1 bg-transparent justify-center items-center overflow-hidden shadow-2xl border-slate-200 shadow-black border-8">
<GestureDetector gesture={nativeGesture}>
<ScrollView waitFor={pinchRef} showsVerticalScrollIndicator={false}>
<ScrollView
horizontal
waitFor={pinchRef}
showsHorizontalScrollIndicator={false}>
<Animated.View
style={[
{
flex: 1,
width: '100%',
height: '100%',
minHeight: Dimensions.get('window').height * 2,
minWidth: Dimensions.get('window').width * 2,
justifyContent: 'flex-start',
alignItems: 'flex-start',
// borderWidth: 1,
overflow: 'scroll',
},
animatedStyle,
]}>
{data.users.length > 0 && (
<Node top node={data.users[0]} level={1} number={1} />
)}
</Animated.View>
</ScrollView>
</ScrollView>
</GestureDetector>
</View>
</GestureDetector>
@j-piasecki any update or thought on this ?
I'm not sure what exactly you meant in the previous comments, but in general nesting scroll views to enable panning is not the best solution, especially on Android where, as far as I know, only one of the scroll views can be active so you cannot scroll diagonally.
Using pan gesture along transform
property to move the view respectively might be a better solution.
@j-piasecki it would help me to achieve the experience like google Maps?
what would you do if someone asks you to build a google map like solution in react native?
I am building a family tree of users so the user can focus on nodes, zoom it, and scroll diagonally, what is the best way to do this in react native gesture handling?
I think using transform
property is a better approach. https://github.com/software-mansion/react-native-gesture-handler/issues/2138 might help you, as it generally tries to accomplish the same thing but with an image.
Description
I want to make Google map smooth experience using react-native-reanimated and react-native gesture handler
where one View will have 1000 * 1000 size inside Nested Scroll View one for horizontal and another for vertical scroll behaviour
till now everything is fine but i am facing issue when i pinch the entire View using GestureDetector with pinchGesture Handler
Steps to reproduce
Snack or a link to a repository
https://snack.expo.dev/@rizwan92/pinch-with-gesture
Gesture Handler version
2.8.0
React Native version
0.69.1
Platforms
Android
JavaScript runtime
No response
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Debug mode
Device
Real device
Device model
Xiomi 11 lite NE Android 12 SKQ1.211006.001
Acknowledgements
Yes