Description
When a scrollable (ScrollView/FlatList) is wrapped in a GestureDetector with Gesture.Native() an in-progress scroll is cancelled on Android the moment the touch leaves the view's bounds. For a short horizontal row (e.g. a carousel), a normal horizontal swipe whose finger drifts slightly up or down exits the row's vertical bounds and the scroll cancels mid-gesture, leaving it "stuck." iOS behaves correctly (the scroll continues tracking the finger anywhere on screen, as expected once a gesture is active).
Root cause: NativeViewGestureHandler overrides the base default and sets shouldCancelWhenOutside = true (NativeViewGestureHandler.kt, init { shouldCancelWhenOutside = true };). With that flag, GestureHandler.kt cancels the handler when shouldCancelWhenOutside && !isWithinBounds. The base GestureHandler default is false, so this is specific to the native-view handler.
Steps to reproduce
- Use
Gesture.Native() without additional configuration
- Wrap a ScrollView with it
- Observe it stops scrolling once the swipe leaves the bounds of the scrollview
A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.
https://snack.expo.dev/@mozzius/rngh-native-cancel-when-outside-bug
Gesture Handler version
2.28.0
React Native version
0.81.5
Platforms
Android
JavaScript runtime
Hermes
Workflow
Using Expo Prebuild or an Expo development build
Architecture
Old Architecture (Paper)
Build type
Debug mode
Device
Real device
Device model
Pixel 7a
Acknowledgements
Yes
Description
When a scrollable (ScrollView/FlatList) is wrapped in a GestureDetector with Gesture.Native() an in-progress scroll is cancelled on Android the moment the touch leaves the view's bounds. For a short horizontal row (e.g. a carousel), a normal horizontal swipe whose finger drifts slightly up or down exits the row's vertical bounds and the scroll cancels mid-gesture, leaving it "stuck." iOS behaves correctly (the scroll continues tracking the finger anywhere on screen, as expected once a gesture is active).
Root cause: NativeViewGestureHandler overrides the base default and sets shouldCancelWhenOutside = true (NativeViewGestureHandler.kt, init { shouldCancelWhenOutside = true };). With that flag, GestureHandler.kt cancels the handler when shouldCancelWhenOutside && !isWithinBounds. The base GestureHandler default is false, so this is specific to the native-view handler.
Steps to reproduce
Gesture.Native()without additional configurationA link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.
https://snack.expo.dev/@mozzius/rngh-native-cancel-when-outside-bug
Gesture Handler version
2.28.0
React Native version
0.81.5
Platforms
Android
JavaScript runtime
Hermes
Workflow
Using Expo Prebuild or an Expo development build
Architecture
Old Architecture (Paper)
Build type
Debug mode
Device
Real device
Device model
Pixel 7a
Acknowledgements
Yes