Skip to content

Commit 361b9a8

Browse files
Luna Weifacebook-github-bot
Luna Wei
authored andcommitted
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
1 parent 1819651 commit 361b9a8

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ public void onChildEndedNativeGesture() {
6969
}
7070

7171
public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDispatcher) {
72-
73-
// Ignore if child is handling native gesture
74-
if (mChildHandlingNativeGesture != -1) {
75-
return;
76-
}
77-
7872
boolean supportsHover =
7973
PointerEventHelper.supportsHover(motionEvent.getToolType(motionEvent.getActionIndex()));
8074

@@ -101,6 +95,9 @@ public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDisp
10195
// First down pointer
10296
if (action == MotionEvent.ACTION_DOWN) {
10397

98+
// Reset mChildHandlingNativeGesture like JSTouchDispatcher does
99+
mChildHandlingNativeGesture = -1;
100+
104101
// Start a "down" coalescing key
105102
mDownStartTime = motionEvent.getEventTime();
106103
mTouchEventCoalescingKeyHelper.addCoalescingKey(mDownStartTime);
@@ -119,6 +116,12 @@ public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDisp
119116
return;
120117
}
121118

119+
// If the touch was intercepted by a child, we've already sent a cancel event to JS for this
120+
// gesture, so we shouldn't send any more pointer events related to it.
121+
if (mChildHandlingNativeGesture != -1) {
122+
return;
123+
}
124+
122125
// New pointer goes down, this can only happen after ACTION_DOWN is sent for the first pointer
123126
if (action == MotionEvent.ACTION_POINTER_DOWN) {
124127
mTouchEventCoalescingKeyHelper.incrementCoalescingKey(mDownStartTime);

0 commit comments

Comments
 (0)