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

5fd0f689dd93236074509b7cc541e2bd.jpg

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

实现原理大概如下:

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) // 一分钟后再次请求

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值