第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > css计时动画 vue css 动画animation 倒计时

css计时动画 vue css 动画animation 倒计时

时间:2019-08-09 21:44:41

相关推荐

css计时动画 vue css 动画animation 倒计时

因大屏需求,制作一个倒计时效果,倒计时结束请求接口刷新数据;(记录一下,下次直接用)

实现原理大概如下:

css

.timeNum {

.daoJiShi {

position: fixed;

top: 50%;

left: 50%;

font-size: 150px;

height: 150px;

animation: flipOutY 1s ease both infinite;

-webkit-animation: flipOutY 1s ease both infinite;

-moz-animation: flipOutY 1s ease both infinite;

}

}

@keyframes flipOutY { // 倒计时动画

0% {

-webkit-transform: perspective(400px) rotateY(0deg);

opacity: .8;

transform: scaleX(3) scaleY(3);

margin-top: -225px;

}

100% {

-webkit-transform: perspective(400px) rotateY(90deg);

opacity: 0;

transform: scaleX(0) scaleY(1);

margin-top: -150px;

}

}

html:

{{ timeOut }}

js(vue+ ts):

timeOut:number = 0 // init倒计时设置

daoJiShi:boolean = true

// 方法

timeRun ():void { // 请求倒计时

if (this.timeOut !== 0) {

this.daoJiShi = true

this.timeOut--

setTimeout(() => {

this.timeRun()

}, 1000)

} else {

this.timeOut = 6

this.daoJiShi = false

setTimeout(() => {

this.timeRun()

}, 10 * 1000) // 一分钟后再次请求

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。