|
作者:ForeverGuard,來自原文地址
本文相關(guān)跳坑指南:跳坑《一百三十四》animation動畫相關(guā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就行!
|