Skip to content

Instantly share code, notes, and snippets.

@jasmo2
Last active July 15, 2019 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasmo2/19c596f1afece551bd209106b08d6f11 to your computer and use it in GitHub Desktop.
Save jasmo2/19c596f1afece551bd209106b08d6f11 to your computer and use it in GitHub Desktop.
export function fromRight(duration = 300) {
return {
transitionSpec: {
duration,
easing: Easing.out(Easing.poly(4)),
timing: Animated.timing,
useNativeDriver: true,
},
screenInterpolator: ({ layout, position, scene }) => {
const { index } = scene;
const { initWidth } = layout;
const translateX = position.interpolate({
inputRange: [index - 1, index, index + 1],
outputRange: [initWidth, 0, 0],
});
const opacity = position.interpolate({
inputRange: [index - 1, index - 0.99, index],
outputRange: [0, 1, 1],
});
return { opacity, transform: [{ translateX }] };
},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment