Skip to content

Commit dfdba8d

Browse files
committed
fix: disable animation by default on web for stack
1 parent a3f7a5f commit dfdba8d

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/stack/src/navigators/createStackNavigator.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import { Platform } from 'react-native';
23
import {
34
useNavigationBuilder,
45
createNavigatorFactory,
@@ -26,6 +27,11 @@ function StackNavigator({
2627
screenOptions,
2728
...rest
2829
}: Props) {
30+
const defaultOptions = {
31+
gestureEnabled: Platform.OS === 'ios',
32+
animationEnabled: Platform.OS !== 'web',
33+
};
34+
2935
const { state, descriptors, navigation } = useNavigationBuilder<
3036
StackNavigationState,
3137
StackRouterOptions,
@@ -34,7 +40,16 @@ function StackNavigator({
3440
>(StackRouter, {
3541
initialRouteName,
3642
children,
37-
screenOptions,
43+
screenOptions:
44+
typeof screenOptions === 'function'
45+
? (...args) => ({
46+
...defaultOptions,
47+
...screenOptions(...args),
48+
})
49+
: {
50+
...defaultOptions,
51+
...screenOptions,
52+
},
3853
});
3954

4055
React.useEffect(

packages/stack/src/views/Stack/StackView.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,7 @@ export default class StackView extends React.Component<Props, State> {
292292
return false;
293293
}
294294

295-
return gestureEnabled !== undefined
296-
? gestureEnabled
297-
: Platform.OS !== 'android';
295+
return gestureEnabled !== false;
298296
}
299297

300298
return false;

0 commit comments

Comments
 (0)