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

Fix `onBegin` and `onTouchesDown` events ordering on Android

Open j-piasecki opened this issue 1 year ago • 0 comments

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.

j-piasecki avatar Oct 19 '22 14:10 j-piasecki