Motivation
Right now only one kind of animation is supported in a StackNavigator. It's useful to support different transitions between different screens in a same stack. For example, you may want shared elements transition between a photo grid and the photo's detail screen, and the default system transition when navigating to the settings screen.
Proposed API
const SimpleStack = StackNavigator({
PhotoGrid: {
screen: PhotoGrid,
},
PhotoDetail: {
screen: PhotoDetail,
},
Settings: {
screen: Settings,
},
}, {
transitions: [
{routeNames: ['PhotoGrid', 'PhotoDetail'], transition: SharedElements},
// The rest are default: CardStack
]
});
Or, better yet, determine the transition dynamically:
{
transition: (fromRoute, toRoute) => {
const routeNames = [ fromRoute.routeName, toRoute.routeName];
return (routeNames.includes('PhotoGrid') && routeNames.includes('PhotoDetail')
? SharedElements
: CardStack);
}
}
Implementation Plan
With a minor change to CardStack, which exposes transitionProps and prevTransitionProps to the transitionConfig prop function, we can implement this for simple transitions such as opacity or translateX/Y animations. @ericvicenti also mentioned an approach to allow each screen to define what Card component to use. This should give more flexibility on how individual screens are animated during the transition.
However, for more complex transitions that require information from multiple screens, such as the shared elements transition, we'd need some extra support. See #175.
Motivation
Right now only one kind of animation is supported in a StackNavigator. It's useful to support different transitions between different screens in a same stack. For example, you may want shared elements transition between a photo grid and the photo's detail screen, and the default system transition when navigating to the settings screen.
Proposed API
Or, better yet, determine the transition dynamically:
Implementation Plan
With a minor change to
CardStack, which exposestransitionPropsandprevTransitionPropsto thetransitionConfigprop function, we can implement this for simple transitions such as opacity or translateX/Y animations. @ericvicenti also mentioned an approach to allow each screen to define what Card component to use. This should give more flexibility on how individual screens are animated during the transition.However, for more complex transitions that require information from multiple screens, such as the shared elements transition, we'd need some extra support. See #175.