I am developing a React Native application which uses React Navigation to manage the routing between screens.
I know reading React Navigation documentation and watching this video on Egghead.io (highly suggested) that is possible to define custom animations for transitions between screens passing the transitionConfig property to a StackNavigator.
For example, the following code is defining a slide from left animation that is basically the mirror of the iOS default push animation:
const TransitionConfig = () => ({
screenInterpolator: ({ layout, position, scene }) => {
const { index } = scene
const { initWidth } = layout
const translateX = position.interpolate({
inputRange: [index - 1, index, index + 1],
outputRange: [-initWidth, 0, 0],
})
return {
transform: [{ translateX }],
}
}
})
const MyNavigator = createStackNavigator(
{
A: {screen: ScreenA},
B: {screen: ScreenB},
},
{ transitionConfig: TransitionConfig }
)
Considering the code above and the fact we are navigating from screen A to screen B, the screenInterpolator function body is basically describing the animation the screen B should follow when it's going to appear (it's reverted when it disappears). In this case the code it's saying to translate the screen B along the X axis to achieve a slide in effect.
Is it possible to also define the animation for the screen that is disappearing (screen A in our case)? I would like to define something like this:
Bshould appear sliding from left to rightAshould disappear sliding from top to bottom

