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

建设部标准定额研究所网站品牌策划网站推荐

建设部标准定额研究所网站,品牌策划网站推荐,wordpress 页面 微博,宣传片拍摄预算表效果 实现方式 计时器#xff1a;setTimeout或setInterval来计时。setInterval和 setTimeout 在某些情况下可能会出现计时不准确的情况。这通常是由于JavaScript的事件循环机制和其他代码执行所需的时间造成的。 问询#xff1a;通过getCurrentLight将每个状态的持续时间设置…效果 实现方式 计时器setTimeout或setInterval来计时。setInterval和 setTimeout 在某些情况下可能会出现计时不准确的情况。这通常是由于JavaScript的事件循环机制和其他代码执行所需的时间造成的。 问询通过getCurrentLight将每个状态的持续时间设置为精确的值并使用requestAnimationFrame来递归调用getCurrentLight函数我们可以更准确地控制交通灯的状态。 源码 index.html !DOCTYPE html htmlheadtitle交通灯/titlelink typetext/css relstyleSheet href./index.css //headbodydiv classtraffic-lightdiv classtraffic-containerdiv classlight green/divdiv classlight yellow/divdiv classlight red/div/divdiv classtime90/div/divscript typemoduleimport {TrafficLight} from ./TrafficLight.js;const time document.querySelector(.time);const trafficDom document.querySelector(.traffic-light);const light new TrafficLight({red:3,yellow:2,green:5,initial:red,});function raf(){requestAnimationFrame((){raf();const current light.getCurrentLight();time.textContent current.remain;trafficDom.className traffic-light ${current.color};console.log(current.color,current.remain);})}raf();/script/body /htmlindex.css * {margin: 0;padding: 0;box-sizing: border-box; }body{width: 100vw;height: 100vh;margin: 0;/* backgroud: #191c29 */background: #fff; }.traffic-light{width: 200px;margin: 10px auto;-webkit-box-flex: inherit;text-align: center; }.light{width: 20px;height: 20px;border-radius: 10px;display:inline-block;background-color: gray;margin: 10px auto; }.red .red{background-color: red; }.green .green{background-color: green; } .yellow .yellow{background-color: yellow; }.time{font-family: DS-Digital;font-size: 40px; }TrafficLight.js export class TrafficLight {constructor(options) {const {red 60,green 60,yellow 3,initial green,} options || {};this._colors {red:{seconds: red,next:yellow,},green:{seconds: green,next:yellow,},yellow:{seconds : yellow,},};this._switch(initial);}_switch(color){this._currentColor color;this._seconds this._colors[color].seconds;this._time Date.now();}_next(){if(this._currentColor red){this._colors.yellow.next green;} else if(this._currentColor green){this._colors.yellow.next red;} else{}this._switch(this._colors[this._currentColor].next); }getCurrentLight(){const remain Math.ceil(this._seconds -(Date.now() - this._time)/1000);if(remain0){this._next();return this.getCurrentLight();}return {color: this._currentColor,remain,};}}字体 DS-Digital 下载字体 DS-Digital 注意下载安装字体后需要重启浏览器才生效
http://www.hkea.cn/news/14425268/

相关文章:

  • 怎么看网站开发的技术怎么建设网站让国外看
  • 做网站经费wordpress 获取文章数
  • 公司建设网站有什么好处展厅策划方案
  • 如何做自己的个人网站网站伪静态怎么设置
  • 淘宝可做的团购网站深圳企业网站建设费用明细
  • 大望路网站建设沈阳看男科哪家医院好
  • 网站推广多少钱WordPress mx 主题
  • php做在线直播网站赣州网站推广多少钱
  • 北京建站公司谷歌排名推广公司
  • 佳匠网站建设江西赣州公司
  • 四川建设工程网上合同备案网站网站百度知道怎么做推广
  • flash 网站设计中国建设人才专业服务网
  • 网站做编辑高校工会网站建设
  • 有记事本做简易网站深圳福田中学
  • 做网站用jsp还是j2ee常州市建设局网站资质
  • 深圳积分商城网站制作重庆市建设工程信息网官网人
  • 电子商城网站开发公司wordpress 地址 html代码
  • wordpress网站顶部加横幅眉山网站建设公司
  • 福永自适应网站建设怎么做导购网站
  • 陕西省建设厅网站ca验证失败wordpress批量导入文章
  • 有专门做试吃的网站吗学院网站建设项目
  • 电商网站建设服务网站站外链接
  • 钓鱼网站怎么做防护教程济南网红
  • 学院招生网站建设方案网站建设600分站优缺点
  • 左右网站模版网站建设与维护蒋勇从
  • 贵阳门户网站公司网站建设服务公司
  • 个人适合做什么网站wordpress acg站
  • 网站安全性设计wordpress系统加速优化
  • 网站建设公司专业网站开发制作音乐网站 源码
  • 桂林网站优化注意事项网上商店网站设计