diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSTouchDispatcher.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSTouchDispatcher.java index ba8d56be8..86abf04fd 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSTouchDispatcher.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSTouchDispatcher.java @@ -11,7 +11,6 @@ package com.facebook.react.uimanager; import android.view.MotionEvent; import android.view.ViewGroup; - import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.react.common.ReactConstants; @@ -74,12 +73,7 @@ public class JSTouchDispatcher { // this gesture mChildIsHandlingNativeGesture = false; mGestureStartTime = ev.getEventTime(); - mTargetTag = TouchTargetHelper.findTargetTagAndCoordinatesForTouch( - ev.getX(), - ev.getY(), - mRootViewGroup, - mTargetCoordinates, - null); + mTargetTag = findTargetTagAndSetCoordinates(ev); eventDispatcher.dispatchEvent( TouchEvent.obtain( mTargetTag, @@ -103,6 +97,7 @@ public class JSTouchDispatcher { } else if (action == MotionEvent.ACTION_UP) { // End of the gesture. We reset target tag to -1 and expect no further event associated with // this gesture. + findTargetTagAndSetCoordinates(ev); eventDispatcher.dispatchEvent( TouchEvent.obtain( mTargetTag, @@ -116,6 +111,7 @@ public class JSTouchDispatcher { mGestureStartTime = TouchEvent.UNSET; } else if (action == MotionEvent.ACTION_MOVE) { // Update pointer position for current gesture + findTargetTagAndSetCoordinates(ev); eventDispatcher.dispatchEvent( TouchEvent.obtain( mTargetTag, @@ -165,6 +161,12 @@ public class JSTouchDispatcher { } } + private int findTargetTagAndSetCoordinates(MotionEvent ev) { + // This method updates `mTargetCoordinates` with coordinates for the motion event. + return TouchTargetHelper.findTargetTagAndCoordinatesForTouch( + ev.getX(), ev.getY(), mRootViewGroup, mTargetCoordinates, null); + } + private void dispatchCancelEvent(MotionEvent androidEvent, EventDispatcher eventDispatcher) { // This means the gesture has already ended, via some other CANCEL or UP event. This is not // expected to happen very often as it would mean some child View has decided to intercept the