mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix (Pointer|Touch)Events not firing after drag and scroll for ScrollView and HorizontalScrollView
Summary: Changelog: [Android][Fixed] - Fix such that when the scrollviews call `onChildStartedNativeGesture`, they appropriately call `onChildEndedNativeGesture` to unlock the native gesture such that `JSTouchDispatcher` or `JSPointerDispatcher` will continue to emit events. ### How did we find this issue? As React Native is adding pointer event support for different input types, we noticed after pressing and dragging on a ScrollView, hover events would not fire. ### Why was this not an issue before? This was always an issue -- it was just that `JSTouchDispatcher` worked its way around it by explicitly setting `mChildIsHandlingNativeGesture = false` on a `ACTION_DOWN` event, [code pointer](https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSTouchDispatcher.java#L76). Similarly, `JSPointerDispatcher` [copied this logic](https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java#L106). With new hover support in `JSPointerDispatcher` no similar workaround was put in (or even a good place to insert). ### What's next? * As a follow-up, we should look at removing this workaround (at least for `JSPointerDispatcher`) * By searching for usages of where we `notifyNativeGestureStarted`, it looks like `ReactDrawerLayout` and `ReactSwipeRefreshLayout` both do and don't call the symmetric `notifyNativeGestureEnded`. This will likely be an issue in the future (or maybe if we remove the workaround) Reviewed By: mdvacca Differential Revision: D37977982 fbshipit-source-id: 0d18767f4debbf24cfb24b54df1310f6f96a0d03
This commit is contained in:
committed by
Facebook GitHub Bot
parent
27fe6f1079
commit
143a0f74b8
+1
@@ -532,6 +532,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
|
||||
float velocityX = mVelocityHelper.getXVelocity();
|
||||
float velocityY = mVelocityHelper.getYVelocity();
|
||||
ReactScrollViewHelper.emitScrollEndDragEvent(this, velocityX, velocityY);
|
||||
NativeGestureUtil.notifyNativeGestureEnded(this, ev);
|
||||
mDragging = false;
|
||||
// After the touch finishes, we may need to do some scrolling afterwards either as a result
|
||||
// of a fling or because we need to page align the content
|
||||
|
||||
@@ -404,6 +404,7 @@ public class ReactScrollView extends ScrollView
|
||||
float velocityX = mVelocityHelper.getXVelocity();
|
||||
float velocityY = mVelocityHelper.getYVelocity();
|
||||
ReactScrollViewHelper.emitScrollEndDragEvent(this, velocityX, velocityY);
|
||||
NativeGestureUtil.notifyNativeGestureEnded(this, ev);
|
||||
mDragging = false;
|
||||
// After the touch finishes, we may need to do some scrolling afterwards either as a result
|
||||
// of a fling or because we need to page align the content
|
||||
|
||||
Reference in New Issue
Block a user