微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

微信小程序连续旋转动画this.animation.rotate

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

添加animation属性

rush:html;toolbar:false">data:{
animation:''"
}

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

rush:html;toolbar:false">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属性

rush:html;toolbar:false">

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。