微信小程序 連續(xù)旋轉(zhuǎn)動畫(this.animation.rotate)詳解
更新時間:2017年04月07日 10:41:47 作者:ForeverGuard
這篇文章主要介紹了微信小程序 連續(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就行!
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關文章
javascript實現(xiàn)檢驗的各種規(guī)則
這篇文章主要介紹了javascript實現(xiàn)檢驗的各種規(guī)則,涉及javascript針對手機號、郵箱、網(wǎng)址、漢字及圖片等相關檢測技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-07-07
前端插件之Bootstrap Dual Listbox使用教程
這篇文章主要介紹了前端插件之Bootstrap Dual Listbox使用教程,本文給大家介紹的非常詳細,具有一定的參考借鑒價值 ,需要的朋友可以參考下2019-07-07

