我正在使用 Stack Navigator 和 transitionConfig 。在场景插值器中,我定义了 myCustomTransition(),该对象将应用于堆栈中的所有屏幕。
是否可以将 myCustomTransition()仅应用于特定屏幕,而将默认堆栈导航器过渡应用于其余屏幕?< / p>
这是 transitionConfig :
const transitionConfig = () => {
return {
transitionSpec: {
duration: 500,
easing: Easing.out(Easing.poly(4)),
timing: Animated.timing,
useNativeDriver: true,
},
screenInterpolator: sceneProps => {
const { scene, position, layout } = sceneProps;
const sceneIndex = scene.index;
const height = layout.initHeight;
// is it possible to have a switch statement
switch (scene.route.routeName) {
case 'searchScreen':
return myCustomTransition();
default:
return defaultTransition();
}
},
};
};
是否可以有一个switch语句将 myCustomTransition()仅应用于 searchScreen ?
谢谢。
答案 0 :(得分:0)
@Vinay Sharma使用此
示例:
const AppStack = createStackNavigator(
{
headerMode: "none",
animationEnabed: true,
transitionConfig: () => ({
transitionSpec: {
easing: Easing.bezier(.88,0.83,.82,.95),
delay: 100,
duration: 250,
},
}),
}
);