Repeat animation with new animated api

后端 未结 8 871
时光取名叫无心
时光取名叫无心 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:20

    You can set another animation then call the animation again:

    An example I did to fade text in and out:

      textAnimate: function() {
        Animated.timing(
          this.state.textOpacity,
          {
            toValue: 0.3,                         
            duration: 500, 
          }
        ).start(() => {
          Animated.timing(  
            this.state.textOpacity,            
            {
              toValue: 1,                    
              duration: 500,          
            }
          ).start(() => {
              this.textAnimate();
            });
        });    
      },
    
      componentDidMount: function() {
        this.state.textOpacity.setValue(1)
        this.textAnimate();
      },
    

提交回复
热议问题