-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
Platform: iOSThis issue is specific to iOSThis issue is specific to iOSRepro providedA reproduction with a snack or repo is providedA reproduction with a snack or repo is provided
Description
Description
According to the docs, requireExternalGestureToFail is like the inverse of blocksExternalGesture.
However, I can't actually get requireExternalGestureToFail to do anything useful with a native gesture.
In particular, I want to block ScrollView if my Pan is being recognized.
The docs lead me to believe that this code would work:
import {View} from 'react-native'
import {
Gesture,
GestureDetector,
GestureHandlerRootView,
ScrollView,
} from 'react-native-gesture-handler'
export default function App() {
const pan = Gesture.Pan()
.onBegin(() => {
'worklet'
console.log('begin')
})
.onUpdate(() => {
'worklet'
console.log('update')
})
.onEnd(() => {
'worklet'
console.log('end')
})
.onFinalize(() => {
'worklet'
console.log('finalize')
})
return (
<GestureHandlerRootView>
<GestureDetector gesture={pan}>
<View style={{flex: 1, backgroundColor: 'blue'}}>
<ScrollViewExample pan={pan} />
</View>
</GestureDetector>
</GestureHandlerRootView>
)
}
function ScrollViewExample({pan}) {
const native = Gesture.Native().requireExternalGestureToFail(pan)
return (
<GestureDetector gesture={native}>
<ScrollView
horizontal
pagingEnabled
style={{
flex: 1,
backgroundColor: 'yellow',
}}>
<View
style={{
width: 200,
height: '100%',
backgroundColor: 'green',
}}
/>
<View
style={{
width: 200,
height: '100%',
backgroundColor: 'purple',
}}
/>
</ScrollView>
</GestureDetector>
)
}But it doesn't do anything. The ScrollView is still in control of the gesture.
Steps to reproduce
- Drag the ScrollView
- The ScrollView gets dragged, but it should have been blocked by the Pan
this_shouldnt_be_dragggable.mov
Snack or a link to a repository
https://snack.expo.dev/k1-MTyYfvD3wQNk3sr_je
Gesture Handler version
2.20.2
React Native version
0.76.3
Platforms
iOS
JavaScript runtime
Hermes
Workflow
Expo bare workflow
Architecture
Paper (Old Architecture)
Build type
Debug mode
Device
Real device
Device model
No response
Acknowledgements
Yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Platform: iOSThis issue is specific to iOSThis issue is specific to iOSRepro providedA reproduction with a snack or repo is providedA reproduction with a snack or repo is provided