fix: disable animation by default on web for stack

This commit is contained in:
Satyajit Sahoo
2020-04-10 17:02:32 +02:00
parent a3f7a5feba
commit dfdba8d741
2 changed files with 17 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import * as React from 'react';
import { Platform } from 'react-native';
import {
useNavigationBuilder,
createNavigatorFactory,
@@ -26,6 +27,11 @@ function StackNavigator({
screenOptions,
...rest
}: Props) {
const defaultOptions = {
gestureEnabled: Platform.OS === 'ios',
animationEnabled: Platform.OS !== 'web',
};
const { state, descriptors, navigation } = useNavigationBuilder<
StackNavigationState,
StackRouterOptions,
@@ -34,7 +40,16 @@ function StackNavigator({
>(StackRouter, {
initialRouteName,
children,
screenOptions,
screenOptions:
typeof screenOptions === 'function'
? (...args) => ({
...defaultOptions,
...screenOptions(...args),
})
: {
...defaultOptions,
...screenOptions,
},
});
React.useEffect(

View File

@@ -292,9 +292,7 @@ export default class StackView extends React.Component<Props, State> {
return false;
}
return gestureEnabled !== undefined
? gestureEnabled
: Platform.OS !== 'android';
return gestureEnabled !== false;
}
return false;