react-native-gesture-handler
react-native-gesture-handler copied to clipboard
fix: android - onstart on pinch gesture handler
Description
This PR attempts to fix onStart callback on android with PinchGestureHandler and resolve the below inconsistency on android and iOS. Fixes https://github.com/software-mansion/react-native-gesture-handler/issues/553
On iOS
- onStart callback gets called during a Pinch (with two finger) gesture.
On Android
- onStart callback gets called even when a single finger is tapped and
focalXandfocalYare always 0 during onStart.
This PR can cause a breaking change for someone who's depending upon using onStart for single-finger gestures on Android (doesn't seem very likely with PinchGestureHandler, but I am not sure!)
Test plan
- Use
useAnimatedGestureHandleras shown below and print values offocalXandfocalYornumberOfPointersinonStartcallback. - Verify the consistency of
onStarton Android and iOS. -
onStartshould be called with 2 finger pinch (similar to iOS). -
focalXandfocalYshould not be 0.
const handler = useAnimatedGestureHandler<PinchGestureHandlerGestureEvent>({
onStart(e, ctx: any) {
console.log(e.focalX, e.focalY)
},
});
// Attach the handler to PinchGestureHandler
<PinchGestureHandler onGestureEvent={handler}>
<Animated.View
style={{ height: 300, width: 300, backgroundColor: "pink" }}
/>
</PinchGestureHandler>
Thanks for looking into it. I can confirm the issue.