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 - Pinch gesture handler when one finger is lifted #1800

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

intergalacticspacehighway

Description

I agree with the notion of preserving the platform behaviour on iOS but in case of android there's no native pinch handler and some custom logic is already there in place, so I am not sure what behavior is correct.

Approach

  • End the gesture on ACTION_UP. i.e. both fingers are lifted.
  • Added a property in PinchGestureHandler to control the numberOfPointer during ACTION_POINTER_UP

Test plan

  • We can test it with the below snippet. Pinch handler will only move to end state when both the fingers are lifted.
  • This gist can also be tested. With the changes in this PR, the gist code will run same in both the platforms.
const handler = useAnimatedGestureHandler<PinchGestureHandlerGestureEvent>({
    onActive(e) {
      console.log("Active")
    },
    onEnd(e) {
      console.log("Ended")
    }
});


// Attach the handler to PinchGestureHandler
<PinchGestureHandler onGestureEvent={handler}>
      <Animated.View
        style={{ height: 300, width: 300, backgroundColor: "pink" }}
      />
</PinchGestureHandler>

@wcandillon
Copy link

I can confirm that Android behaves differently from iOS there

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.

None yet

2 participants