当前位置: 首页 > news >正文

vue做企业网站国家开发投资集团

vue做企业网站,国家开发投资集团,郑州新闻联播,wordpress用户验证失败css计时器 animation实现计时器延时器 缺点当切页面导航会休眠不执行 最初需求是一个列表每个项目都有各自的失效时间 然后就想到 计时器延时器轮询等方案 这些方案每一个都要有自己的计时器 感觉不是很好 轮询也占资源 然后突发奇想 css能不能实现 开始想到的是transition测…

css计时器 animation实现计时器延时器

缺点当切页面导航会休眠不执行

最初需求是一个列表每个项目都有各自的失效时间 然后就想到 计时器延时器轮询等方案 这些方案每一个都要有自己的计时器 感觉不是很好 轮询也占资源 然后突发奇想 css能不能实现 开始想到的是transition测试结果限制太大 然后就想到了动画 可以设置动画的执行时间 重复次数 延迟执行等 这些和计时器延时器类似 然后就去找js的监听事件 发现有监听动画的事件 经过测试 发现还可以

以下为测试的demo  动画的事件可以随意更改 如color width transform 看自己的需求

可以将 animation-delay放到style中 实现每个元素独立的延时器效果

vue框架

<template><div class="box"><!-- 使用v-bind动态添加样式 --><div class="move" :style="{ animationDelay: '5s' }" @animationend="onDelayEnd"@webkitAnimationEnd="onDelayEnd"><div class="no"></div><div class="off"></div></div><div class="box"><div class="move2"@animationiteration="onIntervalIteration"@webkitAnimationIteration="onIntervalIteration"><div class="no"></div><div class="off"></div></div></div></div>
</template><script>
export default {data() {return {delayCount: 0,intervalCount: 0,};},methods: {onDelayEnd() {console.log('延时器 setTimeout');// 在此处可以添加延时器结束后的处理逻辑},onIntervalIteration() {this.intervalCount++;console.log('计时器 setInterval ' + this.intervalCount);// 在此处可以添加计时器每次迭代时的处理逻辑},},
};
</script><style scoped>
.box {width: 50px;height: 50px;margin: 0 auto;border: 2px solid #ccc;overflow: hidden;
}.move,
.move2 {position: relative;width: 100px;height: 50px;display: flex;justify-content: flex-start;
}.move {animation-name: move;animation-duration: 0;animation-fill-mode: forwards;
}.move2 {animation-name: move2;animation-duration: 1s;animation-iteration-count: infinite;
}.no,
.off {width: 50%;height: 50px;
}.no {background: gold;
}.off {background: black;
}@keyframes move {from {left: 0;}to {left: -50px;}
}@keyframes move2 {from {left: 0;}to {left: -50px;}
}
</style>

原生js

<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title><style type="text/css">.box {width: 50px;height: 50px;margin: 0 auto;border: 2px solid #ccc;overflow: hidden;}.move2,.move {position: relative;width: 100px;height: 50px;display: flex;justify-content: flex-start;}.move {animation-name: move;animation-duration: 0;animation-fill-mode: forwards;}.move2 {animation-name: move2;animation-duration: 1s;animation-iteration-count: infinite;}.off,.no {width: 50%;height: 50px;}.no {background: gold;}.off {background: black;}@keyframes move {from {left: 0}to {left: -50px}}@keyframes move2 {from {left: 0}to {left: -50px}}</style></head><body><div class="box">
<!--  style="animation-delay: 5s" 写到行内是因为可以动态添加 --><div class="move" style="animation-delay: 5s"><div class="no"></div><div class="off"></div></div></div><div class="box"><div class="move2"><div class="no"></div><div class="off"></div></div></div></body><script type="text/javascript">document.getElementsByClassName('move')[0].addEventListener('animationend', function() {console.log('延时器 setTimeout')});let count = 0// let timer = setInterval(() => {// 	console.log(++count)// }, 1000)document.getElementsByClassName('move2')[0].addEventListener('animationiteration', function() {console.log('计时器 setInterval '+ ++count)// clearInterval(timer)// count = 0// timer = setInterval(() => {// 	console.log(++count)// }, 1000)});</script>
</html>

http://www.15wanjia.com/news/168838.html

相关文章:

  • 骨干专业群建设任务书网站网站群建设意义
  • 互联网网站开发用哪个语言开发镇江百度推广
  • 做酒类网站成都免费建站模板
  • 北京神州网站建设wordpress商城 注册
  • 网站目的什么网站可以销售自己的产品
  • 深圳十大甲级装饰公司泰安网络推广seo
  • 万润 营销型网站建设代理服务器ip地址和端口号
  • 免费申请qq号官网温州百度推广排名优化
  • 网站建设画册设计杭州装修公司排名前十强
  • 怎样创建基本的网站许昌河南网站建设
  • 织梦网站建设教程微信公众号的网站超链接怎么做
  • 网站建设技术服务合同如何用frontpage做网站
  • 网站底部备案字体设置网站 源码 php
  • 面试网站开发php的网站怎么做的
  • 网站备案流程阿里云怎么登录企业邮箱
  • 高佣联盟做成网站怎么做设计欣赏
  • vs2015做的网站wordpress mysql调整
  • 免费网站开发软件有哪些鄂州网上房地产
  • 做网站的重点目标郑州建设网站费用
  • 一个完整的网站设计购物网站导航模板
  • 网站默认地区数据修改网站页面设计合同
  • 如何搭建情侣网站京东商城官网自营店
  • 营销型网站建设方案演讲ppt杭州搭建网站
  • 天津高端网站建设制作北京网站排行榜
  • 雄县做网站北京市政建设集团有限责任公司网站
  • 商城做网站好还是淘宝怎么用手机建网站
  • 建设银行网站诚聘英才怎么设置网站权限
  • 网站seo收费汝阳县建设局网站
  • 多语言社交网站开发wordpress 伪静态设置
  • 买个网站需要多少钱开发流程图