微信小程序開發(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)文章
JavaScript作用域深度剖析之動(dòng)態(tài)作用域
這篇文章主要為大家介紹了?JavaScript作用域?qū)W習(xí)之動(dòng)態(tài)作用域深度剖析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05
JavaScript通過字符串調(diào)用函數(shù)的實(shí)現(xiàn)方法
這篇文章主要介紹了JavaScript通過字符串調(diào)用函數(shù)的實(shí)現(xiàn)方法,實(shí)例分析了javascript動(dòng)態(tài)調(diào)用函數(shù)的技巧,需要的朋友可以參考下2015-03-03
前端使用正則表達(dá)式進(jìn)行校驗(yàn)的方法總結(jié)大全
很多時(shí)候我們需要校驗(yàn)用戶輸入的值是否正確,如果格式固定的,直接把錯(cuò)誤的值傳給后端顯然是不合理的,所以我們要直接在前端進(jìn)行正則校驗(yàn),這篇文章主要給大家介紹了關(guān)于前端使用正則表達(dá)式進(jìn)行校驗(yàn)的相關(guān)資料,需要的朋友可以參考下2024-07-07
javascript Onunload與Onbeforeunload使用小結(jié)
Onunload,onbeforeunload都是在刷新或關(guān)閉時(shí)調(diào)用,可以在<script>腳本中通過window.onunload來指定或者在<body>里指定。區(qū)別在于onbeforeunload在onunload之前執(zhí)行,它還可以阻止onunload的執(zhí)行。2009-12-12
layui動(dòng)態(tài)設(shè)置單選按鈕選中效果實(shí)例
最近在使用layui前端框架,在使用單選按鈕、下拉菜單select、checkbox等控件的時(shí)候,往往遇到一些初始化的東西,下面這篇文章主要給大家介紹了關(guān)于layui動(dòng)態(tài)設(shè)置單選按鈕選中效果的相關(guān)資料,需要的朋友可以參考下2023-06-06
微信公眾號(hào)平臺(tái)接口開發(fā) 獲取微信服務(wù)器IP地址方法解析
這篇文章主要介紹了微信公眾號(hào)平臺(tái)接口開發(fā) 獲取微信服務(wù)器IP地址方法解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-08-08

