微信小程序 连续旋转动画(this.animation.rotate)详解

有时候阳光很好,有时候阳光很暗,这就是生活。不就应迫求一切种类的快乐,就应只追求高尚的快乐。

微信小程序 连续旋转动画

一、.js中封装旋转动画方法

  添加animation属性

  data:{
    animation:''"
    }

  改变animation的值(官网提供角度范围是-180~180,但是我发现角度越大会一直旋转)

 onShow: function() {
    console.log('index---------onShow()')
     this.animation = wx.createAnimation({
     duration: 1400,
     timingFunction: 'linear', // "linear","ease","ease-in","ease-in-out","ease-out","step-start","step-end"
     delay: 0,
     transformOrigin: '50% 50% 0',
     success: function(res) {
      console.log("res")
     }
    })
   },
   rotateAni: function (n) {
    console.log("rotate=="+n)
    this.animation.rotate(180*(n)).step()
    this.setData({
     animation: this.animation.export()
    })
   },

二、在.wxml中需要的控件上添加animation属性

 <view class="show-iconView">
   <image src="{{src}}" class="show-iconImage" animation="{{animation}}" mode="scaleToFill"></image>
 </view>

三、连续动画需要添加定时器

  this.interval = setInterval所传参数每次++i就行!

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

以上就是微信小程序 连续旋转动画(this.animation.rotate)详解。专注于你所爱的,聚焦于你正在追求的,不要让别人影响你的步履。将真实的世界真正纳入你的眼界,你会发现普通的常识其实并不普通,简单的生活其实也并不简单。你需要重新认识自我,你需要坚定成功的步伐,因为幸运之神只眷顾持续努力的人。更多关于微信小程序 连续旋转动画(this.animation.rotate)详解请关注haodaima.com其它相关文章!

标签: 小程序 animation