【问题标题】:react-native-router-flux navigation direction between scenesreact-native-router-flux 场景之间的导航方向
【发布时间】:2019-03-12 06:11:01
【问题描述】:

版本: react-native-router-flux:v4.0.5,react:v16.4.2,react-native:v0.56.0

我在场景之间导航的情况如下:

场景 A(参数:xA)-> 场景 B(参数:xB)-> 场景 A(参数:yA)-> 场景 B(参数:yB)

这是一种循环。我还应该能够使用 NavBar 中的后退按钮返回上一个场景。

问题在于动画的方向。通常是从右到左。但是当从场景 B(参数:xB)进入场景 A(参数:yA)时,方向是从左到右的(感觉就像点击后退按钮)。我希望这是从右到左的正常方向。

有什么建议吗?

【问题讨论】:

    标签: react-native react-native-router-flux


    【解决方案1】:

    您可以使用您的自定义过渡效果,如下所示并根据您的需要进行修改:

    import StackViewStyleInterpolator from 'react-navigation-stack';
        
        <Scene
        key='main'
        hideNavBar
        transitionConfig={transitionConfig}
        >
        
        ...more scenes
        
        </Scene>
        
        const MyTransitionSpec = ({
            duration: 1000,
            // easing: Easing.bezier(0.2833, 0.99, 0.31833, 0.99),
            // timing: Animated.timing,
        });
        
        const transitionConfig = () => ({
            transitionSpec: MyTransitionSpec,
            // screenInterpolator: StackViewStyleInterpolator.forFadeFromBottomAndroid,
            screenInterpolator: sceneProps => {
                const { layout, position, scene } = sceneProps;
                const { index } = scene;
                const width = layout.initWidth;
        
                //right to left by replacing bottom scene
                // return {
                //     transform: [{
                //         translateX: position.interpolate({
                //             inputRange: [index - 1, index, index + 1],
                //             outputRange: [width, 0, -width],
                //         }),
                //     }]
                // };
        
                const inputRange = [index - 1, index, index + 1];
        
                const opacity = position.interpolate({
                    inputRange,
                    outputRange: ([0, 1, 0]),
                });
        
                const translateX = position.interpolate({
                    inputRange,
                    outputRange: ([width, 0, 0]),
                });
        
                return {
                    opacity,
                    transform: [
                        { translateX }
                    ],
                };
        
                //from center to corners
                // const inputRange = [index - 1, index, index + 1];
                // const opacity = position.interpolate({
                //     inputRange,
                //     outputRange: [0.8, 1, 1],
                // });
        
                // const scaleY = position.interpolate({
                //     inputRange,
                //     outputRange: ([0.8, 1, 1]),
                // });
        
                // return {
                //     opacity,
                //     transform: [
                //         { scaleY }
                //     ]
                // };
            }
        });

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-22
      • 2017-08-19
      • 1970-01-01
      • 2018-01-18
      相关资源
      最近更新 更多