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

Gesture callback differences between platforms #2263

Open
elliotwaite opened this issue Oct 7, 2022 · 0 comments
Open

Gesture callback differences between platforms #2263

elliotwaite opened this issue Oct 7, 2022 · 0 comments
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided

Comments

@elliotwaite
Copy link

elliotwaite commented Oct 7, 2022

Description

For certain gestures, the callbacks that are called, or the order in which they are called, differs between platforms. I listed the difference I've found below. The tables show the order of events from top to bottom.

Tap gesture (if pressed quickly):

iOS Android
onTouchesDown onBegin
onBegin onTouchesDown
onTouchesUp onTouchesUp
onStart onStart
onEnd onEnd
onFinalize onFinalize

Tap gesture (if pressed and held):

iOS Android
onTouchesDown onBegin
onBegin onTouchesDown
onTouchesCancelled onTouchesCancelled
onFinalize onFinalize
onFinalize (a second time)

LongPress gesture (if pressed quickly):

iOS Android
onTouchesDown onBegin
onBegin onTouchesDown
onTouchesUp onTouchesUp
onFinalize onFinalize

LongPress gesture (if pressed and held):

iOS Android
onTouchesDown onBegin
onBegin onTouchesDown
onStart onStart
onTouchesUp onTouchesUp
onEnd onEnd
onFinalize onFinalize

Fling gesture (when a fling is detected):

iOS Android
onBegin onBegin
onTouchesDown onTouchesDown
onTouchesMove (possibly multiple) onTouchesMove (possibly multiple)
onStart onStart
onEnd onTouchesCancelled
onFinalize onEnd
onTouchesCancelled onFinalize

Pinch gesture, Rotation gesture, and Native gesture (when pressed):

iOS Android
onBegin
onTouchesDown onTouchesDown
onTouchesUp onTouchesUp
onFinalize

Manual gesture (when pressed). In the provided Snack, this only happens on the first press because the gesture is never finalized:

iOS Android
onTouchesDown onBegin
onBegin onTouchesDown
onTouchesUp onTouchesUp

Steps to reproduce

  1. Open the provided Snack in two different windows and load one with iOS and one with Android.
  2. Click the gesture buttons on the left and view the log of the callbacks that were called on the right to observe the differences.
  3. You can clear the log by clicking the "Clear Log" button.

Snack or a link to a repository

https://snack.expo.dev/@elliotwaite/rngh-event-order-test

Gesture Handler version

2.5.0

React Native version

0.69.0

Platforms

Android, iOS

JavaScript runtime

No response

Workflow

No response

Architecture

No response

Build type

No response

Device

No response

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided labels Oct 7, 2022
j-piasecki added a commit that referenced this issue Nov 2, 2022
## Description

This PR updates the ordering of events for `Fling` and `Pan` gestures so
that the `onTouchesDown` callback is invoked before `onBegin`.

Fixes part of
#2263.

## Test plan

Tested on the code from the issue and on the example app.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

No branches or pull requests

1 participant