Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change android animation direction #2177

Closed
scriptfans opened this issue Aug 3, 2017 · 14 comments
Closed

how to change android animation direction #2177

scriptfans opened this issue Aug 3, 2017 · 14 comments

Comments

@scriptfans
Copy link

Version

  • react-native-router-flux v4.0.0-beta.14
  • react-native v0.46.4

Expected behaviour

the new scene should be animated horizontal.

Actual behaviour

on Android, It's animated from bottom to top, but there is no problem with iOS, how to change it use horizontal direction? thanks.

untitled

@aksonov
Copy link
Owner

aksonov commented Aug 3, 2017

You should use 'modal' prop for container Scene for bottom to top animation

@aksonov aksonov closed this as completed Aug 3, 2017
@scriptfans
Copy link
Author

@aksonov but I want to use left-right animation, It now always from bottom to top on android. this is my code:
`

    <Scene hideNavBar>

      <Scene key="launch" component={Launch} type='reset' initial />

      <Scene key="login" component={Login} type='reset' />

      <Scene key="sign_up" component={Registration} />

      <Scene key="home" component={Home} />
    </Scene>
  </Router>

`

@aksonov
Copy link
Owner

aksonov commented Aug 3, 2017

Oh I misunderstood then. It is really strange, could you check pure react-navigation demos on Android? RNRF uses react-navigation internally. Could you reproduce this issue on Example project from this repo?

@aksonov aksonov reopened this Aug 3, 2017
@scriptfans
Copy link
Author

thanks for reply, there is no problem with iOS:
untitled
I will test the demo code on Android, thanks.

@scriptfans
Copy link
Author

@aksonov Demo code has the same problem on android:

untitled

so is it a bug?

@aksonov
Copy link
Owner

aksonov commented Aug 3, 2017

Yes, it is a bug. Let's find where is it - within RNRF or within react-navigation. Try this intro: https://reactnavigation.org/docs/intro/

@aksonov
Copy link
Owner

aksonov commented Aug 3, 2017

Ops, looks like it is not bug but a "feature" - I see the same behaviour at that tutorial for Android!

@scriptfans
Copy link
Author

omg.

@aksonov
Copy link
Owner

aksonov commented Aug 3, 2017

@aksonov
Copy link
Owner

aksonov commented Aug 7, 2017

It is default android behaviour, closing the ticket.

@devanshsanghvi
Copy link

i am facing the same, is it possible for us to change transition animation

@Blapi
Copy link
Collaborator

Blapi commented Dec 7, 2017

@Devansh-Sanghvi check #2628

@ajaykumar97
Copy link

You an use your custom transition effects like as follow:

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 }
        //     ]
        // };
    }
});

@sogangCSmaster
Copy link

You an use your custom transition effects like as follow:

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 }
        //     ]
        // };
    }
});

This does not work..using RNRF v4.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants