feat: disable pan gesture by default in the browser for Apple devices

fixes #287
This commit is contained in:
Evan Bacon
2020-01-27 23:26:44 -08:00
committed by Satyajit Sahoo
parent 72993c6463
commit b277927925
2 changed files with 21 additions and 2 deletions

View File

@@ -94,11 +94,30 @@ type Props = {
gestureHandlerProps?: React.ComponentProps<typeof PanGestureHandler>;
};
/**
* Disables the pan gesture by default on Apple devices in the browser.
* https://stackoverflow.com/a/9039885
*/
function shouldEnableGesture(): boolean {
if (
Platform.OS === 'web' &&
typeof navigator !== 'undefined' &&
typeof window !== 'undefined'
) {
const isWebAppleDevice =
/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
return !isWebAppleDevice;
}
return true;
}
export default class DrawerView extends React.PureComponent<Props> {
static defaultProps = {
drawerPostion: I18nManager.isRTL ? 'left' : 'right',
drawerType: 'front',
gestureEnabled: true,
gestureEnabled: shouldEnableGesture(),
swipeEdgeWidth: 32,
swipeVelocityThreshold: 500,
keyboardDismissMode: 'on-drag',

View File

@@ -205,7 +205,7 @@ export default function DrawerView({
<DrawerGestureContext.Provider value={drawerGestureRef}>
<Drawer
open={isDrawerOpen}
gestureEnabled={gestureEnabled !== false}
gestureEnabled={gestureEnabled}
onOpen={handleDrawerOpen}
onClose={handleDrawerClose}
onGestureRef={ref => {