重复运动(左>右 , 左>右)

wxml

  
      
          
      
  

js

Page({
  data:{
        animation:''
  },
   onReady: function () {  
      var circleCount = 0;  
      // 心跳的外框动画  
//    this.animationMiddleHeaderItem = wx.createAnimation({  
//      duration:1000,    // 以毫秒为单位  
//      timingFunction: 'linear',  
//      delay: 100,  
//      transformOrigin: '50% 50%'
//    });  
        
      setInterval(function() {  
      	this.animationMiddleHeaderItem = wx.createAnimation({  
        duration:1000,    // 以毫秒为单位  
        timingFunction: 'linear',  
        delay: 100,  
        transformOrigin: '50% 50%'
      });  
        if (circleCount % 2 == 0) {  
          this.animationMiddleHeaderItem.translate(100).step();  
        } else {  
//        this.animationMiddleHeaderItem.translate(0).step();  
        }  
          
        this.setData({  
          animationMiddleHeaderItem: this.animationMiddleHeaderItem.export()  
        });  
          
        circleCount++;  
        if (circleCount == 1000) {  
          circleCount = 0;  
        }  
      }.bind(this), 1000);  
       setInterval(function() {  
       	this.animationMiddleHeaderItem = wx.createAnimation({  
        duration:0,    // 以毫秒为单位  
        timingFunction: 'linear',  
        delay: 0,  
        transformOrigin: '50% 50%'
      });  
       this.animationMiddleHeaderItem.translate(0).step();  
       this.setData({  
          animationMiddleHeaderItem: this.animationMiddleHeaderItem.export()  
        });  
       }.bind(this),2000)
    }

})

你可能感兴趣的:(小程序)