Repeat animation with new animated api

后端 未结 8 870
时光取名叫无心
时光取名叫无心 2021-01-31 14:40

React-native introduce new Animated API, I want to make a loop animation such as a bubble scale up then scale down and repeat that progress.

However I can n

8条回答
  •  醉酒成梦
    2021-01-31 15:24

    improved version of @bcomerford answer

    //this.state.animatedStartValue = 0;
    
    function cycleAnimation() {
      Animated.sequence([
        Animated.timing(this.state.animatedStartValue, {
          toValue: 1,
          duration: 500,
          delay: 1000
        }),
        Animated.timing(this.state.animatedStartValue, {
          toValue: 0,
          duration: 500
       })
      ]).start(event => {
        if (event.finished) {
          cycleAnimation();
        }
      });
    }
    

提交回复
热议问题