微信小程序開發(fā)animation心跳動(dòng)畫效果
本文實(shí)例為大家分享了微信小程序開發(fā)animation心跳動(dòng)畫,供大家參考,具體內(nèi)容如下
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" style="width:32rpx; height:32rpx;" 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
});
}
})
效果圖:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
js獲得指定控件輸入光標(biāo)的坐標(biāo)兼容IE,Chrome,火狐等多種主流瀏覽器
js獲得指定控件光標(biāo)的坐標(biāo),兼容IE,Chrome,火狐等多種主流瀏覽器,實(shí)現(xiàn)代碼及調(diào)用代碼如下,感興趣的朋友可以參考下哈,希望對(duì)你有所幫助2013-05-05
跟我學(xué)習(xí)javascript的嚴(yán)格模式
跟我學(xué)習(xí)javascript的嚴(yán)格模式,對(duì)javascript嚴(yán)格模式進(jìn)行概述,進(jìn)入嚴(yán)格模式的方法,以及如何調(diào)用和相關(guān)語法,感興趣的小伙伴們可以參考一下2015-11-11
uniapp在開發(fā)app時(shí)上傳文件時(shí)的問題記錄
在開發(fā)uniapp應(yīng)用時(shí),可能會(huì)遇到文件上傳功能在iOS和部分Android手機(jī)上不兼容的問題,經(jīng)過對(duì)比分析,發(fā)現(xiàn)問題可能出在文件的路徑上,通過使用uni.saveFile方法保存文件后,再上傳可以解決問題,這篇文章詳細(xì)介紹了解決方案,并引導(dǎo)讀者參考更多相關(guān)內(nèi)容2024-09-09
微信小程序基于movable-view實(shí)現(xiàn)滑動(dòng)刪除效果
這篇文章主要介紹了微信小程序基于movable-view實(shí)現(xiàn)滑動(dòng)刪除效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-01-01
javascript htmlencode函數(shù)(ff兼容版) 主要是編輯器中反轉(zhuǎn)html代碼
非常不錯(cuò)的htmlencode 方法,比用正則實(shí)現(xiàn)的更好,而且效率高,推薦使用第一種方法。2009-06-06

