我想从右到左和从左到右为我的组件设置动画:
const CardCashout: FC<CardCashoutProps> = ({ openCard }) => {
const left = new Animated.Value(0);
useEffect(() => {
if (openCard)
Animated.timing(left, {
toValue: 0,
duration: 5000,
easing: Easing.inOut(Easing.ease),
}).start();
else {
Animated.timing(left, {
toValue: 222,
duration: 5000,
easing: Easing.out(Easing.ease),
}).start();
}
}, [openCard]);
return (
<Animated.View style={{ transform: [{ translateX: left }] }}>
<Text>CardCashout</Text>
</Animated.View>
);
};
当opencard为false时,向右转为动画,但是当opecard为true时我尝试切换它时,没有动画发生吗?