Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: android - onstart on pinch gesture handler #1798

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

intergalacticspacehighway
Copy link

@intergalacticspacehighway intergalacticspacehighway commented Jan 2, 2022

Description

This PR attempts to fix onStart callback on android with PinchGestureHandler and resolve the below inconsistency on android and iOS. Fixes #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>

@intergalacticspacehighway intergalacticspacehighway changed the title fix: android - call onstart on pinch gesture fix: android - onstart on pinch gesture Jan 2, 2022
@intergalacticspacehighway intergalacticspacehighway changed the title fix: android - onstart on pinch gesture fix: android - onstart on pinch gesture handler Jan 2, 2022
@wcandillon
Copy link

Thanks for looking into it. I can confirm the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PinchGestureHandler State.BEGAN inconsistency on Android/iOS
2 participants