Skip to content

Commit d82a220

Browse files
committedJun 11, 2017
custom modal transition
1 parent b513f26 commit d82a220

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed
 

‎app/models/router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
})
3333
// debounce, see https://github.com/react-community/react-navigation/issues/271
3434
if (payload.type === 'Navigation/NAVIGATE') {
35-
yield call(delay, 250)
35+
yield call(delay, 500)
3636
}
3737
}
3838
},

‎app/router.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { PureComponent } from 'react'
2-
import { BackHandler } from 'react-native'
2+
import { BackHandler, Animated, Easing } from 'react-native'
33
import {
44
StackNavigator,
55
TabNavigator,
@@ -49,6 +49,30 @@ const AppNavigator = StackNavigator(
4949
navigationOptions: {
5050
gesturesEnabled: false,
5151
},
52+
transitionConfig: () => ({
53+
transitionSpec: {
54+
duration: 300,
55+
easing: Easing.out(Easing.poly(4)),
56+
timing: Animated.timing,
57+
},
58+
screenInterpolator: sceneProps => {
59+
const { layout, position, scene } = sceneProps
60+
const { index } = scene
61+
62+
const height = layout.initHeight
63+
const translateY = position.interpolate({
64+
inputRange: [index - 1, index, index + 1],
65+
outputRange: [height, 0, 0],
66+
})
67+
68+
const opacity = position.interpolate({
69+
inputRange: [index - 1, index - 0.99, index],
70+
outputRange: [0, 1, 1],
71+
})
72+
73+
return { opacity, transform: [{ translateY }] }
74+
},
75+
}),
5276
}
5377
)
5478

0 commit comments

Comments
 (0)
Please sign in to comment.