Reactjs 基于参数的React Navigation 5.x导航过渡动画

Reactjs 基于参数的React Navigation 5.x导航过渡动画,reactjs,react-native,animation,react-navigation,Reactjs,React Native,Animation,React Navigation,是否可以基于特定传递的参数启用/禁用导航过渡动画 navigation.navigate('SomeScreen', { data: someData, withAnimation: true, }); 在上面的示例中,withAnimation参数设置为true,因此我希望此处设置的动画(forRevealFromBottomAndroid)处于活动状态: <Stack.Screen name="Some

是否可以基于特定传递的参数启用/禁用导航过渡动画

navigation.navigate('SomeScreen', {
          data: someData,
          withAnimation: true,
        });
在上面的示例中,
withAnimation
参数设置为
true
,因此我希望此处设置的动画(
forRevealFromBottomAndroid
)处于活动状态:

<Stack.Screen
        name="SomeScreen"
        component={SomeScreen}
        options={{
          headerLeft: null,
          headerShown: false,
          cardStyleInterpolator:
            CardStyleInterpolators.forRevealFromBottomAndroid,
        }}
      />

是的,您可以这样做:

let animation = false;
cardStyleInterpolator: animation ? CardStyleInterpolators.forNoAnimation : CardStyleInterpolators.forHorizontalIOS

是的,这是可能的。您可以通过以下方式实现:

let animation = false;
cardStyleInterpolator: animation ? CardStyleInterpolators.forNoAnimation : CardStyleInterpolators.forHorizontalIOS
在导航器中:

<Stack.Screen
        name="SomeScreen"
        component={SomeScreen}
        options={({route: {params}}) => ({
          headerLeft: null,
          headerShown: false,
          cardStyleInterpolator: params?.withAnimation
              ? CardStyleInterpolators.forHorizontalIOS
              : CardStyleInterpolators.forNoAnimation,
        })}
/>