微信小程序 連續(xù)旋轉(zhuǎn)動畫(this.animation.rotate)詳解
微信小程序 連續(xù)旋轉(zhuǎn)動畫
一、.js中封裝旋轉(zhuǎn)動畫方法
添加animation屬性
data:{
animation:''"
}
改變animation的值(官網(wǎng)提供角度范圍是-180~180,但是我發(fā)現(xiàn)角度越大會一直旋轉(zhuǎn))
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>
三、連續(xù)動畫需要添加定時器
this.interval = setInterval所傳參數(shù)每次++i就行!
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
javascript 實(shí)現(xiàn)的多瀏覽器支持的貪吃蛇webgame
兼容FF IE的javascript版貪吃蛇游戲,非常厲害的高手。2008-01-01
JavaScript中this的學(xué)習(xí)筆記及用法整理
在本篇文章里小編給大家整理的是關(guān)于JavaScript中this的使用以及代碼實(shí)例,需要的朋友們學(xué)習(xí)下。2020-02-02
JavaScript實(shí)現(xiàn)的3D旋轉(zhuǎn)魔方動畫效果實(shí)例代碼
在本篇文章里小編給大家整理了關(guān)于JavaScript實(shí)現(xiàn)的3D旋轉(zhuǎn)魔方動畫效果實(shí)例代碼,有興趣的朋友們測試下。2019-07-07

