Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hungdev/c8df18e6507fa240f0d299bd4d9454f3 to your computer and use it in GitHub Desktop.

Select an option

Save hungdev/c8df18e6507fa240f0d299bd4d9454f3 to your computer and use it in GitHub Desktop.
transaction left to right react navigation

transaction left to right react navigation

const transition = () => ({
  screenInterpolator: sceneProps => {
    const { layout, position, scene } = sceneProps;
    const { index } = scene;
    const width = layout.initWidth;

    return {
      opacity: position.interpolate({
        inputRange: [index - 1, index, index + 1],
        outputRange: [0, 1, 0],
      }),
      transform: [{
        translateX: position.interpolate({
          inputRange: [index - 1, index, index + 1],
          outputRange: [-width, 0, width],
        }),
      }]
    };
  },
  headerTitleInterpolator: sceneProps => {
    const { layout, position, scene } = sceneProps;
    const { index } = scene;

    return {
      opacity: position.interpolate({
        inputRange: [index - 1, index, index + 1],
        outputRange: [0, 1, 0],
      }),
      transform: [{
        translateX: position.interpolate({
          inputRange: [index - 1, index, index + 1],
          outputRange: [-50, 0, 50],
        }),
      }]
    };
  },
})

source: react-navigation/react-navigation#2393

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment