gpt4 book ai didi

css - 在一个元素上 react native 动画多个动画

转载 作者:行者123 更新时间:2023-11-27 22:59:14 31 4
gpt4 key购买 nike

有没有办法在一个动画 View 上有多个动画,改变相同的 css 属性?

this.expandAnimation = new Animated.Value(50);
this.shrinkAnimation = new Animated.Value(200);

Animated.sequence([
Animated.timing(this.expandAnimation, {
toValue: 200,
duration: 1000
}),
Animated.timing(this.shrinkAnimation, {
toValue: 50,
duration: 1000
})
]),

<Animated.View style={[styles.box, { width: this.ExpandAnimation }]}> // What value to bind to width?
<View>
</View>
</Animated.View>

最佳答案

由 Federkun 回答。您使用单个动画值。

this.expandAndShrinkAnimation = new Animated.Value(50);

Animated.sequence([
Animated.timing(this.expandAndShrinkAnimation, {
toValue: 200,
duration: 1000
}),
Animated.timing(this.expandAndShrinkAnimation, {
toValue: 50,
duration: 1000
})
]),

<Animated.View style={[styles.box, { width: this.expandAndShrinkAnimation }]}> // What value to bind to width?
<View>
</View>
</Animated.View>


关于css - 在一个元素上 react native 动画多个动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59079786/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com