Skip to content

Commit f301097

Browse files
committed
[android] fix scroll actions interpreted as touch
1 parent cbd97db commit f301097

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,7 @@ open class GestureHandler {
385385
setPointerType(sourceEvent)
386386
}
387387

388-
if (sourceEvent.action == MotionEvent.ACTION_HOVER_ENTER ||
389-
sourceEvent.action == MotionEvent.ACTION_HOVER_MOVE ||
390-
sourceEvent.action == MotionEvent.ACTION_HOVER_EXIT
391-
) {
388+
if (sourceEvent.action.isHoverAction()) {
392389
onHandleHover(adaptedTransformedEvent, adaptedSourceEvent)
393390
} else {
394391
onHandle(adaptedTransformedEvent, adaptedSourceEvent)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,7 @@ class GestureHandlerOrchestrator(
522522
handler !is HoverGestureHandler &&
523523
handler !is RNGestureHandlerRootHelper.RootViewGestureHandler
524524

525-
return shouldSkipHoverEvents &&
526-
action in
527-
listOf(
528-
MotionEvent.ACTION_HOVER_EXIT,
529-
MotionEvent.ACTION_HOVER_ENTER,
530-
MotionEvent.ACTION_HOVER_MOVE,
531-
)
525+
return shouldSkipHoverEvents && action.isHoverAction()
532526
}
533527

534528
private fun recordViewHandlersForPointer(

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ val ReactContext.UIManager: UIManagerModule
1414

1515
fun Context.isScreenReaderOn() =
1616
(getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager).isTouchExplorationEnabled
17+
18+
fun MotionEvent.isHoverAction(): Boolean = action == MotionEvent.ACTION_HOVER_MOVE ||
19+
action == MotionEvent.ACTION_HOVER_ENTER ||
20+
action == MotionEvent.ACTION_HOVER_EXIT

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class RNGestureHandlerRootView(context: Context?) : ReactViewGroup(context) {
4141
}
4242

4343
override fun dispatchGenericMotionEvent(ev: MotionEvent) =
44-
if (rootViewEnabled && rootHelper!!.dispatchTouchEvent(ev)) {
44+
if (rootViewEnabled && ev.action.isHoverAction() && rootHelper!!.dispatchTouchEvent(ev)) {
4545
true
4646
} else {
4747
super.dispatchGenericMotionEvent(ev)

0 commit comments

Comments
 (0)