5

Is it possible to enable/disable the navigation transition animation based on a specifically passed param?

navigation.navigate('SomeScreen', {
          data: someData,
          withAnimation: true,
        });

In the example above, the withAnimation param is set to true, so I want the animation (forRevealFromBottomAndroid) set here to be active:

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

2 Answers 2

8

Yes it's possible. You can achieve it this way:

In your navigator:

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

Where you navigate:

navigation.navigate('SomeScreen', {
    data: someData,
    withAnimation: true
});
Sign up to request clarification or add additional context in comments.

Comments

0

Yes, you can do this way:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.