我想让用户能够在堆叠导航器中滑动导航到类似于Instagram的屏幕(向左滑动会把你带到你的消息,动画跟随滑动的速度,如果你按住触摸并缓慢滑动屏幕移动很长时间)。
我不想嵌套一个底部/顶部导航器来做这件事。我可以将transitionConfig道具配置为类似的动画,但动画是被触发的,并且对手势没有响应(慢慢滑动会使其慢慢显示下一个屏幕,等等)。只有当你滑动返回时,它才能完美地工作,而不是导航到新屏幕。
附注:我想使用堆栈导航器来做这件事,而不是使用可滚动视图或类似的东西
export default createStackNavigator({
bottomNavigator,
Profile: Profile,
tempScreen: TempScreen
}, {
transitionConfig: (prop) => NavigationConfig(prop)
})下面是NavigationConfig返回的动画
const trackFromRightToLeft = {
transitionSpec: {
duration: 350
},
screenInterpolator: sceneProps => {
const { position, layout, scene } = sceneProps
const thisSceneIndex = scene.index
const width = layout.initWidth
const translateX = position.interpolate({
inputRange: [thisSceneIndex - 1, thisSceneIndex, thisSceneIndex + 1],
outputRange: [width, 0, -width]
})
const slideFromRight = { transform: [{ translateX }] }
return slideFromRight
},
}发布于 2019-04-04 17:53:50
您可以使用react-native-gesture-handler中的分页程序,这并不完全是您想要的,但是通过一些逻辑,您可以实现它
https://stackoverflow.com/questions/55506814
复制相似问题