react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

fix: android - onstart on pinch gesture handler

Open intergalacticspacehighway opened this issue 2 years ago • 1 comments

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 and focalY 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 of focalX and focalY or numberOfPointers in onStart callback.
  • Verify the consistency of onStart on Android and iOS.
  • onStart should be called with 2 finger pinch (similar to iOS).
  • focalX and focalY 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.

wcandillon avatar Jan 12 '22 08:01 wcandillon