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
focalX
andfocalY
are 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
useAnimatedGestureHandler
as shown below and print values offocalX
andfocalY
ornumberOfPointers
inonStart
callback. - Verify the consistency of
onStart
on Android and iOS. -
onStart
should be called with 2 finger pinch (similar to iOS). -
focalX
andfocalY
should 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.