微信小程序實現(xiàn)下拉刷新動畫
更新時間:2019年06月21日 10:29:31 作者:CodeHunter_qcy
這篇文章主要為大家詳細介紹了微信小程序動畫實現(xiàn)下拉刷新動畫,具有一定的參考價值,感興趣的小伙伴們可以參考一下
微信小程序動畫之下拉刷新動畫的具體代碼,供大家參考,具體內(nèi)容如下

簡易的效果
下面放代碼:
js:
var animation = wx.createAnimation({})
var i = 1;
Page({
data: {
donghua: true,
left1: Math.floor(Math.random() * 250 + 1),
left2: Math.floor(Math.random() * 250 + 1),
left3: Math.floor(Math.random() * 250 + 1),
left4: Math.floor(Math.random() * 250 + 1),
left5: Math.floor(Math.random() * 250 + 1),
left6: Math.floor(Math.random() * 250 + 1),
left7: Math.floor(Math.random() * 250 + 1),
left8: Math.floor(Math.random() * 250 + 1),
},
//動畫
donghua: function () {
var that = this;
setTimeout(function () {
animation.translateY(800).step({
duration: 1600,
timingFunction: 'ease'
})
that.setData({
["animationData" + i]: animation.export()
})
i++;
}.bind(that), 200)
if (i < 9) {
setTimeout(function () {
that.donghua()
}.bind(that), 200)
} else {
i = 0;
animation.translateY(-800).step({
duration: 10,
})
setTimeout(function () {
for (var y = 0; y < 9; y++) {
that.setData({
["animationData" + y]: animation.export()
})
that.setData({
["animationData" + y + '.actions[0].animates[0].args[0]']: 0
})
}
}.bind(that), 1500)
}
},
onPullDownRefresh: function () {
wx.showNavigationBarLoading();
this.donghua();
wx.stopPullDownRefresh();
},
})
wxml:
<!-- 動畫 -->
<block wx:if="{{donghua}}">
<view class='donghua'>
<image bindtap='hua' style='left:{{left1}}px' animation="{{animationData1}}" src='../../images/1.png'></image>
<image bindtap='hua' style='left:{{left2}}px' animation="{{animationData2}}" src='../../images/2.png'></image>
<image bindtap='hua' style='left:{{left3}}px' animation="{{animationData3}}" src='../../images/3.png'></image>
<image bindtap='hua' style='left:{{left4}}px' animation="{{animationData4}}" src='../../images/1.png'></image>
<image bindtap='hua' style='left:{{left5}}px' animation="{{animationData5}}" src='../../images/2.png'></image>
<image bindtap='hua' style='left:{{left6}}px' animation="{{animationData6}}" src='../../images/3.png'></image>
<image bindtap='hua' style='left:{{left7}}px' animation="{{animationData7}}" src='../../images/1.png'></image>
<image bindtap='hua' style='left:{{left8}}px' animation="{{animationData8}}" src='../../images/2.png'></image>
</view>
</block>
wxss:
image{
margin-top: -150rpx;
width: 40rpx;
height: 40rpx;
margin-left: 5%;
position: absolute;
}
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
使用Chrome調(diào)試JavaScript的斷點設置和調(diào)試技巧
這篇文章主要介紹了使用Chrome調(diào)試JavaScript的斷點設置和調(diào)試技巧,需要的朋友可以參考下2014-12-12
探索export導出一個字面量會報錯export?default不會報錯
這篇文章主要為大家介紹了export導出一個字面量會報錯而export?default不會報錯的問題探索解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2024-01-01
JS實現(xiàn)動態(tài)修改table及合并單元格的方法示例
這篇文章主要介紹了JS實現(xiàn)動態(tài)修改table及合并單元格的方法,結合完整實例形式分析了JS動態(tài)遍歷及修改table單元格的具體操作技巧,需要的朋友可以參考下2017-02-02

