微信小程序 連續(xù)旋轉動畫(this.animation.rotate)詳解
更新時間:2017年04月07日 10:41:47 作者:ForeverGuard
這篇文章主要介紹了微信小程序 連續(xù)旋轉動畫(this.animation.rotate)詳解的相關資料,需要的朋友可以參考下
微信小程序 連續(xù)旋轉動畫
一、.js中封裝旋轉動畫方法
添加animation屬性
data:{ animation:''" }
改變animation的值(官網提供角度范圍是-180~180,但是我發(fā)現角度越大會一直旋轉)
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所傳參數每次++i就行!
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關文章
前端插件之Bootstrap Dual Listbox使用教程
這篇文章主要介紹了前端插件之Bootstrap Dual Listbox使用教程,本文給大家介紹的非常詳細,具有一定的參考借鑒價值 ,需要的朋友可以參考下2019-07-07