2 回答

TA贡献1995条经验 获得超2个赞
您可以StackCardInterpolationProps
从导入类型react-navigation
https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/types.tsx

TA贡献1845条经验 获得超8个赞
在 React 导航 6 中
查看in的类型定义StackCardStyleInterpolator
@react-navigation
。这应该适用于 Stack 中的动画屏幕。
forSlideFromLeft
您可以像这样实现您的方法:
import {
StackCardInterpolationProps,
StackCardInterpolatedStyle,
} from "@react-navigation/stack";
const forSlideFromLeft = (
{ current, layouts, index }: StackCardInterpolationProps
): StackCardInterpolatedStyle => {
const translateX = current.progress.interpolate({
inputRange: [0, 1],
outputRange: [-layouts.screen.width, 0],
});
if (index === 2) {
return {
cardStyle: {
transform: [{ translateX }],
},
};
} else {
return {};
}
};
还有一个StackHeaderStyleInterpolator
用于动画标题的。
添加回答
举报