React-native-router-flux: How to disable fade out animation for previous scene?

Created on 22 Feb 2017  路  1Comment  路  Source: aksonov/react-native-router-flux

I would like to disable the fade out & scale animation that is used on the current scene when navigating to a new scene. Is there a way to do that?

Most helpful comment

yes of course feel free to use animationStyle property on

Here is a hint for you:

<Provider>
<Router  animationStyle={animationStyle} />
</Provider>


export const animationStyle = (props) => {
  const { layout, position, scene } = props;

  const direction = (scene.navigationState && scene.navigationState.direction) ?
    scene.navigationState.direction : 'horizontal';

  const index = scene.index;

  const inputRange = [index - 1, index, index + 1];
  const width = layout.initWidth;
  const height = layout.initHeight;

  const opacity = position.interpolate({
    inputRange,
    outputRange: [1, 1, 1], //This will prevent the scene from Fading out
  });

  const scale = position.interpolate({
    inputRange,
    outputRange: [1, 1, 1], //This will keep the scale the same
  });

  let translateX = 0;
  let translateY = 0;

  switch (direction) {
    case 'horizontal':
      translateX = position.interpolate({
        inputRange,
        outputRange: [width, 0, -10],
      });
      break;
    case 'vertical':
      translateY = position.interpolate({
        inputRange,
        outputRange: [height, 0, -10],
      });
      break;
  }

  return {
    opacity,
    backgroundColor: 'transparent', // Fixes white border
    transform: [
      { scale },
      { translateX },
      { translateY },
    ],
  };
};

Go ahead and interpolate those values aka play with them, to meet your needs :)

Hope this helps 馃憤

>All comments

yes of course feel free to use animationStyle property on

Here is a hint for you:

<Provider>
<Router  animationStyle={animationStyle} />
</Provider>


export const animationStyle = (props) => {
  const { layout, position, scene } = props;

  const direction = (scene.navigationState && scene.navigationState.direction) ?
    scene.navigationState.direction : 'horizontal';

  const index = scene.index;

  const inputRange = [index - 1, index, index + 1];
  const width = layout.initWidth;
  const height = layout.initHeight;

  const opacity = position.interpolate({
    inputRange,
    outputRange: [1, 1, 1], //This will prevent the scene from Fading out
  });

  const scale = position.interpolate({
    inputRange,
    outputRange: [1, 1, 1], //This will keep the scale the same
  });

  let translateX = 0;
  let translateY = 0;

  switch (direction) {
    case 'horizontal':
      translateX = position.interpolate({
        inputRange,
        outputRange: [width, 0, -10],
      });
      break;
    case 'vertical':
      translateY = position.interpolate({
        inputRange,
        outputRange: [height, 0, -10],
      });
      break;
  }

  return {
    opacity,
    backgroundColor: 'transparent', // Fixes white border
    transform: [
      { scale },
      { translateX },
      { translateY },
    ],
  };
};

Go ahead and interpolate those values aka play with them, to meet your needs :)

Hope this helps 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vinayr picture vinayr  路  3Comments

YouYII picture YouYII  路  3Comments

xnog picture xnog  路  3Comments

basdvries picture basdvries  路  3Comments

fgrs picture fgrs  路  3Comments