mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-12 22:51:18 +08:00
fix: disable animation by default on web for stack
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user