Closed mlecoq closed 3 years ago
you can achieve your goal with passing the NativeViewGestureHandler
ref to BottomSheet
or BottomSheetModal
waitFor
prop, like:
<BottomSheet
{...}
waitFor={nativeGestureRef}
>
<BottomSheetView style={styles.container}>
<NativeViewGestureHandler
ref={nativeGestureRef}
disallowInterruption={true}
>
<MapView {...} />
</NativeViewGestureHandler>
</BottomSheetView>
</BottomSheet>
@mlecoq let me know if the post above solves your issue ๐
I will check, thanks !
@gorhom yes it works well, thanks a lot !
In case someone will be using this with expo 48 and react-native-gesture-handler 2.9.0, you can do it like this:
const BottomSheetMap = () => {
const panGestureRef = useRef(Gesture.Pan())
const pinchGesture = Gesture.Pinch().withRef(panGestureRef)
return (
<BottomSheet
{...}
waitFor={panGestureRef}
>
<BottomSheetView style={styles.container}>
<GestureDetector
gesture={pinchGesture}
// @ts-expect-error: this prop is not added in types but it's working
disallowInterruption={true}
>
<MapView {...} />
</GestureDetector>
</BottomSheetView>
</BottomSheet>
)
}
Adding the disallowInterruption={true}
prop to Gesture Detector solves all issues, but looks like the library is not expecting to receiving this prop, it's possible that in next releases this will need another update ๐
In case someone will be using this with expo 48 and react-native-gesture-handler 2.9.0, you can do it like this:
const BottomSheetMap = () => { const panGestureRef = useRef(Gesture.Pan()) const pinchGesture = Gesture.Pinch().withRef(panGestureRef) return ( <BottomSheet {...} waitFor={panGestureRef} > <BottomSheetView style={styles.container}> <GestureDetector gesture={pinchGesture} // @ts-expect-error: this prop is not added in types but it's working disallowInterruption={true} > <MapView {...} /> </GestureDetector> </BottomSheetView> </BottomSheet> ) }
Adding the
disallowInterruption={true}
prop to Gesture Detector solves all issues, but looks like the library is not expecting to receiving this prop, it's possible that in next releases this will need another update ๐
OMG, this charm should go straight to the readme docs
Bug
I have added a map (from react-native-mapbox) in a bottom sheet. On Android, pinch and zoom are in conflict with bottom sheet behavior (on iOS everything works fine). I have tried to wrap MapView with a NativeViewGestureHandler as suggested in the documentation
I can move within my map, pinch tends to move bottom sheet and zoom has no visual effect.
Here is my bottom sheet
Box is from
native-base
Environment info
Steps To Reproduce
Describe what you expected to happen:
Reproducible sample code
I have made a small example here: https://github.com/mlecoq/bottomsheet-map
To get a token from mapbox, you need to have an account : https://account.mapbox.com/auth/signup/
And then replace
MAPBOX_ACCESS_TOKEN
in the code