Last active
July 18, 2019 11:31
-
-
Save jasmo2/ff4364f4d00d8e8f28beda6f510d4ef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* At this point the method receive and object | |
* which has duration as well as percentageRange | |
* that will be in charge of pushing the outgoing | |
* screen | |
*/ | |
export function fromRight({ duration = 300, percentageRange = 0 }) { | |
return { | |
transitionSpec: { | |
duration, | |
easing: customCurve, | |
timing: Animated.timing, | |
useNativeDriver: true, | |
}, | |
screenInterpolator: ({ layout, position, scene }) => { | |
const { index } = scene | |
const { initWidth } = layout | |
// Here the caculation base on the screen is been made. | |
const finalWidth = -initWidth * percentageRange | |
const translateX = position.interpolate({ | |
inputRange: [index - 1, index, index + 1], | |
outputRange: [initWidth, 0, finalWidth], | |
}) | |
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