小編給大家分享一下微信小程序如何開發(fā)animation心跳動(dòng)畫效果,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
成都一家集口碑和實(shí)力的網(wǎng)站建設(shè)服務(wù)商,擁有專業(yè)的企業(yè)建站團(tuán)隊(duì)和靠譜的建站技術(shù),十年企業(yè)及個(gè)人網(wǎng)站建設(shè)經(jīng)驗(yàn) ,為成都數(shù)千家客戶提供網(wǎng)頁設(shè)計(jì)制作,網(wǎng)站開發(fā),企業(yè)網(wǎng)站制作建設(shè)等服務(wù),包括成都營銷型網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計(jì),同時(shí)也為不同行業(yè)的客戶提供網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)的服務(wù),包括成都電商型網(wǎng)站制作建設(shè),裝修行業(yè)網(wǎng)站制作建設(shè),傳統(tǒng)機(jī)械行業(yè)網(wǎng)站建設(shè),傳統(tǒng)農(nóng)業(yè)行業(yè)網(wǎng)站制作建設(shè)。在成都做網(wǎng)站,選網(wǎng)站制作建設(shè)服務(wù)商就選創(chuàng)新互聯(lián)建站。
1、微信小程序開發(fā)animation心跳動(dòng)畫
wxml文件中:
<view class="bottomViewItem"> <view class="bottomMiddleHeaderView" bindtap="voteClick" data-id="value"> <view class="bottomMiddleHeaderItem" animation="{{animationMiddleHeaderItem}}"> <!-- 心跳 --> <view class="bottomMiddleHeaderItemSubView"> <image src="/images/detail_vote_heart.png" animation="{{animationMiddleHeaderItem}}"></image> </view> <!-- 投票文字 --> <view class="bottomMiddleHeaderItemSubView">投票</view> </view> </view> </view>
js文件中:
// 頁面渲染完成 onReady: function () { var circleCount = 0; // 心跳的外框動(dòng)畫 this.animationMiddleHeaderItem = wx.createAnimation({ duration:1000, // 以毫秒為單位 /** * http://cubic-bezier.com/#0,0,.58,1 * linear 動(dòng)畫一直較為均勻 * ease 從勻速到加速在到勻速 * ease-in 緩慢到勻速 * ease-in-out 從緩慢到勻速再到緩慢 * * http://www.tuicool.com/articles/neqMVr * step-start 動(dòng)畫一開始就跳到 100% 直到動(dòng)畫持續(xù)時(shí)間結(jié)束 一閃而過 * step-end 保持 0% 的樣式直到動(dòng)畫持續(xù)時(shí)間結(jié)束 一閃而過 */ timingFunction: 'linear', delay: 100, transformOrigin: '50% 50%', success: function (res) { } }); setInterval(function() { if (circleCount % 2 == 0) { this.animationMiddleHeaderItem.scale(1.15).step(); } else { this.animationMiddleHeaderItem.scale(1.0).step(); } this.setData({ animationMiddleHeaderItem: this.animationMiddleHeaderItem.export() }); circleCount++; if (circleCount == 1000) { circleCount = 0; } }.bind(this), 1000); },
2、微信顯示倒計(jì)時(shí)
wxml文件中:
<!--倒計(jì)時(shí) --> <view class="countDownTimeView countDownAllView" > <view class="voteText countDownTimeText">{{countDownDay}}天</view> <view class="voteText countDownTimeText">{{countDownHour}}時(shí)</view> <view class="voteText countDownTimeText">{{countDownMinute}}分</view> <view class="voteText countDownTimeText">{{countDownSecond}}秒</view> </view>
js文件中:
Page( { data: { windowHeight: 654, maxtime: "", isHiddenLoading: true, isHiddenToast: true, dataList: {}, countDownDay: 0, countDownHour: 0, countDownMinute: 0, countDownSecond: 0, }, //事件處理函數(shù) bindViewTap: function() { wx.navigateTo( { url: '../logs/logs' }) }, onLoad: function() { this.setData( { windowHeight: wx.getStorageSync( 'windowHeight' ) }); }, // 頁面渲染完成后 調(diào)用 onReady: function () { var totalSecond = 1505540080 - Date.parse(new Date())/1000; var interval = setInterval(function () { // 秒數(shù) var second = totalSecond; // 天數(shù)位 var day = Math.floor(second / 3600 / 24); var dayStr = day.toString(); if (dayStr.length == 1) dayStr = '0' + dayStr; // 小時(shí)位 var hr = Math.floor((second - day * 3600 * 24) / 3600); var hrStr = hr.toString(); if (hrStr.length == 1) hrStr = '0' + hrStr; // 分鐘位 var min = Math.floor((second - day * 3600 *24 - hr * 3600) / 60); var minStr = min.toString(); if (minStr.length == 1) minStr = '0' + minStr; // 秒位 var sec = second - day * 3600 * 24 - hr * 3600 - min*60; var secStr = sec.toString(); if (secStr.length == 1) secStr = '0' + secStr; this.setData({ countDownDay: dayStr, countDownHour: hrStr, countDownMinute: minStr, countDownSecond: secStr, }); totalSecond--; if (totalSecond < 0) { clearInterval(interval); wx.showToast({ title: '活動(dòng)已結(jié)束', }); this.setData({ countDownDay: '00', countDownHour: '00', countDownMinute: '00', countDownSecond: '00', }); } }.bind(this), 1000); }, //cell事件處理函數(shù) bindCellViewTap: function (e) { var id = e.currentTarget.dataset.id; wx.navigateTo({ url: '../babyDetail/babyDetail?id=' + id }); } })
效果圖:
以上是“微信小程序如何開發(fā)animation心跳動(dòng)畫效果”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站標(biāo)題:微信小程序如何開發(fā)animation心跳動(dòng)畫效果
轉(zhuǎn)載來源:http://www.chinadenli.net/article8/peiiop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、網(wǎng)站設(shè)計(jì)、關(guān)鍵詞優(yōu)化、電子商務(wù)、企業(yè)建站、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)