Skip to content

Commit 1384cc7

Browse files
committed
Add right side transition animation
1 parent ad144fa commit 1384cc7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/index.js

+28
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@ export function fromLeft(duration = 300) {
2727
};
2828
}
2929

30+
export function fromRight(duration = 300) {
31+
return {
32+
transitionSpec: {
33+
duration,
34+
easing: Easing.out(Easing.poly(4)),
35+
timing: Animated.timing,
36+
useNativeDriver: true
37+
},
38+
screenInterpolator: ({ layout, position, scene }) => {
39+
const { index } = scene
40+
const { initWidth } = layout
41+
42+
const translateX = position.interpolate({
43+
inputRange: [index - 1, index, index + 1],
44+
outputRange: [initWidth, 0, 0]
45+
})
46+
47+
const opacity = position.interpolate({
48+
inputRange: [index - 1, index - 0.99, index],
49+
outputRange: [0, 0, 1]
50+
})
51+
52+
return { opacity, transform: [{ translateX }] }
53+
}
54+
}
55+
}
56+
57+
3058
export function fromTop(duration = 300) {
3159
return {
3260
transitionSpec: {

0 commit comments

Comments
 (0)