react-native-gesture-handler
react-native-gesture-handler copied to clipboard
Fix `onBegin` and `onTouchesDown` events ordering on Android
Description
This PR changes the ordering of onBegin
and onTouchesDown
events on Android. onBegin
was invoked first, as some gestures required additional setup when they started tracking the first pointer, which is happening after the touch events are dispatched. The workaround for that was to send onTouchesDown
later but it resulted in inconsistent behavior between platforms.
The gesture initialization is now abstracted to the parent class and may be invoked by touch events. The one caveat is that it requires an instance of MotionEvent
so one needs to be remembered when dispatching the touch event.
Fixes part of https://github.com/software-mansion/react-native-gesture-handler/issues/2263.
Test plan
Tested on the example app and on the code from the issue.