PointerEvents: Reset childHandlingNativeGesture on first ACTION_DOWN

Summary:
Changelog: [Internal] - Reset the mChildHandlingNativeGesture on the first ACTION_DOWN after it's been set.

I noticed this issue when scrolling sometimes in the event log for the W3CPointerEvents example, none of the pointer events would get captured because we'd call [`notifyNativeGestureStarted`](https://www.internalfb.com/code/fbsource/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/NativeGestureUtil.java?lines=25-25) which would prevent any pointerevents being fired.

Reviewed By: vincentriemer

Differential Revision: D35685378

fbshipit-source-id: 01fc255afc5e22dc6c42f7eb11a8aa5a9a091b87
This commit is contained in:
Luna Wei
2022-04-19 15:22:00 -07:00
committed by Facebook GitHub Bot
parent 18196512db
commit 361b9a808c
@@ -69,12 +69,6 @@ public class JSPointerDispatcher {
}
public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDispatcher) {
// Ignore if child is handling native gesture
if (mChildHandlingNativeGesture != -1) {
return;
}
boolean supportsHover =
PointerEventHelper.supportsHover(motionEvent.getToolType(motionEvent.getActionIndex()));
@@ -101,6 +95,9 @@ public class JSPointerDispatcher {
// First down pointer
if (action == MotionEvent.ACTION_DOWN) {
// Reset mChildHandlingNativeGesture like JSTouchDispatcher does
mChildHandlingNativeGesture = -1;
// Start a "down" coalescing key
mDownStartTime = motionEvent.getEventTime();
mTouchEventCoalescingKeyHelper.addCoalescingKey(mDownStartTime);
@@ -119,6 +116,12 @@ public class JSPointerDispatcher {
return;
}
// If the touch was intercepted by a child, we've already sent a cancel event to JS for this
// gesture, so we shouldn't send any more pointer events related to it.
if (mChildHandlingNativeGesture != -1) {
return;
}
// New pointer goes down, this can only happen after ACTION_DOWN is sent for the first pointer
if (action == MotionEvent.ACTION_POINTER_DOWN) {
mTouchEventCoalescingKeyHelper.incrementCoalescingKey(mDownStartTime);