微信小程序開發(fā)animation心跳動畫效果
更新時間:2021年09月23日 09:33:51 作者:Rolan
這篇文章主要為大家詳細(xì)介紹了微信小程序開發(fā)animation心跳動畫效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了微信小程序開發(fā)animation心跳動畫,供大家參考,具體內(nèi)容如下
1、微信小程序開發(fā)animation心跳動畫
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" style="width:32rpx; height:32rpx;" animation="{{animationMiddleHeaderItem}}"></image> </view> <!-- 投票文字 --> <view class="bottomMiddleHeaderItemSubView">投票</view> </view> </view> </view>
js文件中:
// 頁面渲染完成 onReady: function () { var circleCount = 0; // 心跳的外框動畫 this.animationMiddleHeaderItem = wx.createAnimation({ duration:1000, // 以毫秒為單位 /** * http://cubic-bezier.com/#0,0,.58,1 * linear 動畫一直較為均勻 * ease 從勻速到加速在到勻速 * ease-in 緩慢到勻速 * ease-in-out 從緩慢到勻速再到緩慢 * * http://www.tuicool.com/articles/neqMVr * step-start 動畫一開始就跳到 100% 直到動畫持續(xù)時間結(jié)束 一閃而過 * step-end 保持 0% 的樣式直到動畫持續(xù)時間結(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、微信顯示倒計時
wxml文件中:
<!--倒計時 --> <view class="countDownTimeView countDownAllView" > <view class="voteText countDownTimeText">{{countDownDay}}天</view> <view class="voteText countDownTimeText">{{countDownHour}}時</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; // 小時位 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: '活動已結(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 }); } })
效果圖:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
js獲得指定控件輸入光標(biāo)的坐標(biāo)兼容IE,Chrome,火狐等多種主流瀏覽器
js獲得指定控件光標(biāo)的坐標(biāo),兼容IE,Chrome,火狐等多種主流瀏覽器,實現(xiàn)代碼及調(diào)用代碼如下,感興趣的朋友可以參考下哈,希望對你有所幫助2013-05-05跟我學(xué)習(xí)javascript的嚴(yán)格模式
跟我學(xué)習(xí)javascript的嚴(yán)格模式,對javascript嚴(yán)格模式進(jìn)行概述,進(jìn)入嚴(yán)格模式的方法,以及如何調(diào)用和相關(guān)語法,感興趣的小伙伴們可以參考一下2015-11-11微信小程序基于movable-view實現(xiàn)滑動刪除效果
這篇文章主要介紹了微信小程序基于movable-view實現(xiàn)滑動刪除效果,本文通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2020-01-01javascript htmlencode函數(shù)(ff兼容版) 主要是編輯器中反轉(zhuǎn)html代碼
非常不錯的htmlencode 方法,比用正則實現(xiàn)的更好,而且效率高,推薦使用第一種方法。2009-06-06