It depends on the Navigator

For Stack Navigator

Use gestureDirection: 'horizontal-inverted'. An example:

    <Stack.Navigator
      screenOptions={{
        gestureDirection: 'horizontal-inverted',
      }}
    >
      <Stack.Screen name="Login" component={Login} />
      <Stack.Screen name="Register" component={Register} />
    </Stack.Navigator>

For Native Stack Navigator

Use animation: 'slide_from_right'

<Stack.Navigator>
  <Stack.Screen
    name="Home"
    component={HomeScreen}
    options={{animation: 'slide_from_right'}}
  />
  <Stack.Screen
    name="Profile"
    component={ProfileScreen}
    options={{animation: 'slide_from_right'}}
  />
</Stack.Navigator>
Answer from Jacobo Mata on Stack Overflow
Top answer
1 of 6
4

It depends on the Navigator

For Stack Navigator

Use gestureDirection: 'horizontal-inverted'. An example:

    <Stack.Navigator
      screenOptions={{
        gestureDirection: 'horizontal-inverted',
      }}
    >
      <Stack.Screen name="Login" component={Login} />
      <Stack.Screen name="Register" component={Register} />
    </Stack.Navigator>

For Native Stack Navigator

Use animation: 'slide_from_right'

<Stack.Navigator>
  <Stack.Screen
    name="Home"
    component={HomeScreen}
    options={{animation: 'slide_from_right'}}
  />
  <Stack.Screen
    name="Profile"
    component={ProfileScreen}
    options={{animation: 'slide_from_right'}}
  />
</Stack.Navigator>
2 of 6
3

First make this below.

 const leftToRightAnimation = {
  cardStyleInterpolator: ({ current, layouts }) => {
    return {
      cardStyle: {
        transform: [
          {
            translateX: current.progress.interpolate({
              inputRange: [0, 1],
              outputRange: [-layouts.screen.width, 0],
            }),
          },
        ],
      },
    };
  },
};

Basically all it's doing is it's moving the screen from the x direction of full screen width away in left direction to fitting the screen. And implicitly progress is going from 0 to 1.

  • The transform works just like any other react-native component read more here (https://reactnative.dev/docs/transforms).
  • And it uses interpolate from the react-native animated (https://reactnative.dev/docs/animated)

Then put it in the screen you want the transition to apply to.

<NavigationContainer>
      <Root.Navigator headerMode="none" initialRouteName="Home">
        <Root.Screen name="Home" component={Home} />
        <Root.Screen name="NotModal" component={NotModal} options={leftToRightAnimation} />
      </Root.Navigator>
 </NavigationContainer>
🌐
GitHub
github.com › react-navigation › react-navigation › issues › 2393
Simpler Left-to-right Stack Navigation transitions · Issue #2393 · react-navigation/react-navigation
August 16, 2017 - Hi, an application I'm developing requires screen transitions in both normal right-to-left and inverse left-to-right transitions, depending on what screen one is navigating to. It is rather simple to change the direction of the actual ca...
Author   aeirola
Discussions

How to change trasition screen right to left instead bottom to top?
Hi, I'm using RN 0.44.2 and react-navigation 1.0.0-beta.11. And I'm using StackNavigator to change screens, when I change new screen, trasition is bottom to top by defualt. Can I change to ... More on github.com
🌐 github.com
31
June 2, 2017
Left and right navigation with React Navigation
@Make-HCI well you can always define your animation: reactnavigation.org/docs/en/transitioner.html 2018-10-18T00:53:08.223Z+00:00 ... Actually there would be some dirty method too that I wouldn't recommend. When you navigate you could use a reset action that rebuilds the stack where on top of it there is the screen you want to navigate to using a right to left ... More on stackoverflow.com
🌐 stackoverflow.com
October 18, 2018
Stack navigator left to right?
There currently is no way to set the transitionConfig per screen. I think a work around is using nested StackNavigators and setting the transitionConfig differently for each. https://github.com/react-navigation/rfcs/issues/10 (Shameless plug) You can also check out the source code for the fromLeft function in this npm package I created to see how to create an left to right animation https://www.npmjs.com/package/react-navigation-transitions More on reddit.com
🌐 r/reactnative
4
4
August 13, 2018
From left to right window animation with react-navigation? - Stack Overflow
Is there a way to implement animation that goes from left to right with navigate() function in react-navigation ? Thanks in advance. ... Yes, I think it is possible. checkout this reactnavigation.org/docs/views/transitioner More on stackoverflow.com
🌐 stackoverflow.com
October 8, 2017
🌐
React Navigation
reactnavigation.org › docs › stack-navigator
Stack Navigator | React Navigation
These transition animations can ... gestureDirection - The direction of swipe gestures: horizontal - The gesture to close the screen will start from the left, and from the right ......
🌐
GitHub
github.com › react-navigation › react-navigation › issues › 1759
How to change trasition screen right to left instead bottom to top? · Issue #1759 · react-navigation/react-navigation
June 2, 2017 - Hi, I'm using RN 0.44.2 and react-navigation 1.0.0-beta.11. And I'm using StackNavigator to change screens, when I change new screen, trasition is bottom to top by defualt. Can I change to ...
Author   xuho
🌐
npm
npmjs.com › package › react-navigation-slide-from-right-transition
react-navigation-slide-from-right-transition - npm
On iOS, the default transition animation for React Navigation's card stack is a slide from right animation. I had a project which required the same slide from right animation on Android, so I decided to pull out the transition config into this library. See the corresponding issue here to track any potential progress on getting a slide from right transition on Android. ... Now your stack navigator will slide from the right when you push screens onto the stack, and slide to the left when you pop screens off of the stack on Android!
      » npm install react-navigation-slide-from-right-transition
    
Published   Aug 20, 2017
Version   1.0.4
Author   Travis Nuttall
Find elsewhere
🌐
ITNEXT
itnext.io › change-react-native-screen-animation-direction-with-react-navigation-8cec0f66f22
Change React Native screen animation direction with react-navigation | by Justyna Sowińska | ITNEXT
November 1, 2020 - Modal is opening as modal itself, but other screens within modal have stack-like transitions so in left-right direction. On Android you can still see that other screens within Modal stack don’t go right-to-left, but we will talk about it later on. Ok, but what about NotModal screen? When we’ve switched our Root Navigator to the modal mode, all screens within it are now also modal. Fortunately, react-navigation 5 gives us opportunity to add our custom transitions to screens.
🌐
LogRocket
blog.logrocket.com › home › how to use shared element transition with react navigation v5
How to use Shared Element Transition with React Navigation v5 - LogRocket Blog
June 4, 2024 - In the above example, please note that when the transition happens, the screen slides from left to right in between. To modify this behavior to apply transition effects of the shared elements, let’s add an options configuration object to the DetailScreen. In the root navigator file, add the following configuration:
🌐
GitHub
github.com › wix › react-native-navigation › issues › 3869
How to change screen transition (slide) left to right instead of right to left · Issue #3869 · wix/react-native-navigation
August 28, 2018 - I would like to have different transition, slide left to right instead of default behaviour (slide right to left) to open the screen. I have already searched a lot and read also documentation but there is no easy way to only change the default behaviour (change animation direction). React Native Navigation version: ^2.0.2418 ·
Author   marzieh-kazemi
🌐
DEV Community
dev.to › acro5piano › use-the-same-screen-navigation-animation-both-on-android-ios-with-react-native-react-navigation-eng
Use the same screen navigation animation both on Android/iOS with React Native + React Navigation - DEV Community
August 28, 2019 - I would like the animation to slide from left to right in the same way on iOS: The solution is very simple: import { createAppContainer, createStackNavigator, StackViewTransitionConfigs, } from 'react-navigation' const Navigation = createStackNavigator({ screenA: ComponentA, screenB: ComponentB, }, { mode: 'card', transitionConfig: () => StackViewTransitionConfigs.SlideFromRightIOS, } export const AppNavigation = createAppContainer(Navigation) I wonder why this is the default behavior...
🌐
GitHub
github.com › Traviskn › react-navigation-slide-from-right-transition
GitHub - Traviskn/react-navigation-slide-from-right-transition: A slide-from-right transition config for use with react navigation's stack navigator on android
October 19, 2023 - your react component code here ... */ const SimpleStack = StackNavigator({ Home: { screen: MyHomeScreen }, Profile: { path: 'people/:name', screen: MyProfileScreen, }, }, { transitionConfig: getSlideFromRightTransition }); Now your stack navigator will slide from the right when you push screens onto the stack, and slide to the left when you pop screens off of the stack on Android!
Starred by 75 users
Forked by 9 users
Languages   JavaScript 38.9% | Objective-C 36.2% | Python 14.1% | Java 10.8% | JavaScript 38.9% | Objective-C 36.2% | Python 14.1% | Java 10.8%
🌐
npm
npmjs.com › package › react-navigation-transitions
react-navigation-transitions - npm
July 26, 2019 - import { fromLeft } from 'react-navigation-transitions'; ... In the example above, the same transition animation will be used for all screens within the navigator. The example below shows how to use different transitions for specific screens.
      » npm install react-navigation-transitions
    
Published   Jul 26, 2019
Version   1.0.12
Author   Phil Mok
🌐
Reddit
reddit.com › r/reactnative › react-navigation: how to apply different transition animations to the same screen based on the previous screen?
r/reactnative on Reddit: React-Navigation: How to apply different transition animations to the same screen based on the previous screen?
August 19, 2022 -

Using react-navigation v6. I have the following set-up:

ConversationListScreen can navigate to:

  • ConversationScreen -> can navigate back to ConversationListScreen

  • NewConversationScreen -> can navigate back to ConversationListScreen OR ConversationScreen

I want to have a different transition when going to ConversationScreen depending on which screen navigated to it.

For instance, if coming from the ConversationListScreen I want the ConversationScreen to slide from right-to-left, but if it is coming from NewConversationScreen, I simply want it to fade-in.

I have some more complex scenarios, but basically, I need a way to dynamically apply the transitions. Is this possible? They are within the same stack navigator.

Most of my screens are in the same stack, because most can be accessed from many screens. I really hope I don't have to make separate stacks with the same screens just for different transitions.

Edit: Just a note I am using NativeStackNavigators but I can switch to normal stack navigators if needed. When navigating to a different screen/stack I'm mainly using the nav container's ref like so:

navRef.dispatch(CommonActions.navigate({ name: 'ScreenNameHere', params: {} }));
Top answer
1 of 6
66

For react navigation > 5.0:

import {
  CardStyleInterpolators,
  createStackNavigator,
} from '@react-navigation/stack';
    
const Stack = createStackNavigator();
export default () => (
  <Stack.Navigator
    screenOptions={{
      cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS
    }}
  >
    <Stack.Screen name="Screen 1" component={ScreenComponent1} />
    <Stack.Screen name="Screen 2" component={ScreenComponent2} />
  </Stack.Navigator>
);

You may also want to use headerStyleInterpolator: HeaderStyleInterpolators.forUIKit

More info here: https://reactnavigation.org/docs/stack-navigator/#pre-made-configs

2 of 6
17

For react navigation < 5.0

On iOS it's standard behavior. Android requires a little bit of configuration. There are two options you can use to set screen transitions: mode and transitionConfig. In this case transitionConfig will work:

import CardStackStyleInterpolator from 'react-navigation/src/views/CardStack/CardStackStyleInterpolator';
// this path can be different depending on react-navigation version, this one is for @1.0.0-beta.15 

export default StackNavigator ({
    Main: {
        screen: MainScreen,
    },
        ...
}, {
   transitionConfig: () => ({
        screenInterpolator: CardStackStyleInterpolator.forHorizontal,
   }),
})

We use CardStackStyleInterpolator from react-navigation source, but you can provide custom transition if you want, here is how to make one or here or this article.

mode is more for default behavior:

export default StackNavigator ({
    Main: {
        screen: MainScreen,
    },
    ...
}, {
    mode: 'card',
    navigationOptions: ({navigation, screenProps}) => ({
        tabBarOnPress: blahblaj
    }),
    lazy: true
});

mode can have only two values:

  • card - Use the standard iOS (right to left) and Android (bottom to top) screen transitions. This is the default.

  • modal - Make the screens slide in from the bottom which is a common iOS pattern. Only works on iOS, has no effect on Android.

For react navigation >= 5.0:

import {
  CardStyleInterpolators,
  createStackNavigator,
} from '@react-navigation/stack';
    
const Stack = createStackNavigator();
export default () => (
  <Stack.Navigator
    screenOptions={{
      cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS
    }}
  >
    <Stack.Screen name="Screen 1" component={ScreenComponent1} />
    <Stack.Screen name="Screen 2" component={ScreenComponent2} />
  </Stack.Navigator>
);

You may also want to use headerStyleInterpolator: HeaderStyleInterpolators.forUIKit

More info here: https://reactnavigation.org/docs/stack-navigator/#pre-made-configs