[2.2.0] Pinch gesture doesn't start when used in vertical position on Android
See original GitHub issueDescription
The pinch event for start and update don’t get called on android devices when the two fingers have higher absolute Y values than X values and are therefore vertical
Platforms
- iOS
- Android
- Web
Screenshots
https://user-images.githubusercontent.com/420864/155535248-efc0230b-738f-40e0-bd21-847b3984d037.mov
Steps To Reproduce
- Position pinch gesture so index finger and thumb are more vertical than horizontal
- Apply pinch, note that pinch start doesn’t begin
Expected behavior
Pinch should work in both directions on android
Actual behavior
Does not start pinch gesture
Snack or minimal code example
import React from 'react';
import { StyleSheet } from 'react-native';
import {
Gesture,
GestureDetector,
GestureHandlerRootView,
} from 'react-native-gesture-handler';
import Animated, {
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated';
const App = () => {
const scale = useSharedValue(1);
const savedScale = useSharedValue(1);
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ scale: scale.value }],
}));
const gesture = Gesture.Pinch()
.onTouchesDown(() => {
if (event.allTouches.length > 1) {
const [touch1, touch2] = event.allTouches;
direction.value =
Math.abs(touch1.x - touch2.x) > Math.abs(touch1.y - touch2.y)
? 'horizontal'
: 'vertical';
console.log(direction.value);
}
})
.onStart((e) => {
console.log(e.type);
})
.onUpdate((e) => {
scale.value = savedScale.value * e.scale;
})
.onEnd(() => {
savedScale.value = scale.value;
});
return (
<GestureHandlerRootView style={styles.flex}>
<GestureDetector gesture={gesture}>
<Animated.View style={[styles.box, animatedStyle]} />
</GestureDetector>
</GestureHandlerRootView>
);
};
const styles = StyleSheet.create({
flex: { flex: 1, backgroundColor: 'salmon' },
box: {
width: 250,
height: 250,
marginTop: 300,
alignSelf: 'center',
backgroundColor: 'blue',
},
});
export default App;
Package versions
- React: 17.0.2
- React Native: 0.66.4
- React Native Gesture Handler: 2.2.0
- React Native Reanimated: 2.4.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
For ARCore TramsformableNode, Pinch getsture doesn't work ...
Pinch gesture only works after the first touch events, either users touch the 3d object first or drag the 3d object first.
Read more >Pinch gesture | React Native Gesture Handler
A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or...
Read more >MR.Gestures - Touch gestures in MAUI and Xamarin.Forms ...
Fixes a bug where the gestures were not properly reset if you handled Panning but not Panned, Pinching without Pinched or Rotating without...
Read more >What's new - Litchi
Android : Litchi for DJI Drones. Version 4.25.0 (July 4, 2022) - added a media gallery that lets you review and download media...
Read more >New Device Simulator (preview) | Page 4 - Unity Forum
I use the scroll wheel to simulate pinch-to-zoom and ESC to ... The ScreenSettings Orientation value doesn't change to 'upside down' and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe it will work. In case it doesn’t, you can try to wrap the
ScrollView
you are using now withGestureDetector
and set it to recognizeGesture.Native()
. Then you can userequireExternalGestureToFail
on the gesture to accomplish the same effect as withwaitFor
on theScrollView
. It would look something like this:@JB-CHAUVIN i tried your recommendation it is more than good now but, i have tried this nested scroll view for pinch gesture and its is working fine . i would recommned everyone to please import scroll view from react native for more smoothness rather than animated.scrollview
working example