react-router设置动画效果



  • 怎样在路由切换的时候整个页面设置入场动画啊??在网上找的例子都不能实现。。还望大神给个示例



  • const ModalNavigator = createStackNavigator(
    {
    Main: { screen: Main },
    Login: { screen: Login },
    },
    {
    headerMode: 'none',
    mode: 'modal',
    defaultNavigationOptions: {
    gesturesEnabled: false,
    },
    transitionConfig: () => ({
    transitionSpec: {
    duration: 300,
    easing: Easing.out(Easing.poly(4)),
    timing: Animated.timing,
    },
    screenInterpolator: sceneProps => {
    const { layout, position, scene } = sceneProps;
    const { index } = scene;

        const height = layout.initHeight;
        const translateY = position.interpolate({
          inputRange: [index - 1, index, index + 1],
          outputRange: [height, 0, 0],
        });
    
        const opacity = position.interpolate({
          inputRange: [index - 1, index - 0.99, index],
          outputRange: [0, 1, 1],
        });
    
        return { opacity, transform: [{ translateY }] };
      },
    }),
    

    }
    );


Log in to reply