Start multiple Animated.timing at once with React Native

后端 未结 1 474
梦毁少年i
梦毁少年i 2021-02-12 18:15

I\'m trying to start multiple React Native animations at once, with one callback for all animations. The example works fine, but I don\'t like the fact, that I have to start one

相关标签:
1条回答
  • 2021-02-12 18:41

    Yes, there is. You can use Animated.parallel!

    Animated.parallel([
        Animated.timing(this.state.opacity, {
            toValue: 0,
            duration: 300
        }),
        Animated.timing(this.state.height, {
            toValue: 0,
            duration: 300
        })
    ]).start(() => {
        // callback
    });
    
    0 讨论(0)
提交回复
热议问题