JavaScript实现动态时钟效果
作者:? 时间:2024-04-16 10:27:04
演示
时间是非常有限的,过去时光永远不会再回来。要在有限的时间里面,去面对生活的困难和生存的竞争,是需要强化自我的。而这些强化学习是最需时间的。而人的精力又是非常有限的,能用来做有意义的时间少之又少。所以充分利用好有限的时间,才能面对生活的困难和压力。
配置设计
var config={
'language_type':2,
'font_color':'#dce0f6',
'pointer_color':'#09f5ea',
'sound':0,
'sound_name':'bg.mp3',
'background_style':1,
'background_picture':'bg.jpg',
'background_video':'3.mp4',
'background_color':'#000000',
}
旋转功能设计
setTimeout(function () {
$(".year span").css("animation","yearRun 1s linear infinite");
style.insertRule("@keyframes yearRun {0%{transform: rotateZ(0);transform-origin: -"+yearLeft+" "+top+";}100%{transform:rotateZ(720deg);transform-origin: -"+yearLeft+" "+top+";}}",style.rules.length);
$($(".main-content .second span")[0]).removeClass("current");
$(".second span").each(function(index,element){
$(element).css("animation","secondRun"+index+" 1s linear infinite");
style.insertRule("@keyframes secondRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+secondLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+secondLeft+" "+top+";}}",style.rules.length);
});
$($(".main-content .minute span")[0]).removeClass("current");
$(".minute span").each(function(index,element){
$(element).css("animation","minuteRun"+index+" 1s linear infinite");
style.insertRule("@keyframes minuteRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+minuteLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+minuteLeft+" "+top+";}}",style.rules.length);
});
$($(".main-content .hour span")[0]).removeClass("current");
$(".hour span").each(function(index,element){
$(element).css("animation","hourRun"+index+" 1s linear infinite");
style.insertRule("@keyframes hourRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+hourLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+hourLeft+" "+top+";}}",style.rules.length);
});
$($(".main-content .shichen span")[0]).removeClass("current");
$(".shichen span").each(function(index,element){
$(element).css("animation","shichenRun"+index+" 1s linear infinite");
style.insertRule("@keyframes shichenRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+shichenLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+shichenLeft+" "+top+";}}",style.rules.length);
});
$($(".main-content .week span")[0]).removeClass("current");
$(".week span").each(function(index,element){
$(element).css("animation","weekRun"+index+" 1s linear infinite");
style.insertRule("@keyframes weekRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+weekLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+weekLeft+" "+top+";}}",style.rules.length);
});
$($(".main-content .day span")[0]).removeClass("current");
$(".day span").each(function(index,element){
$(element).css("animation","dayRun"+index+" 1s linear infinite");
style.insertRule("@keyframes dayRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+dayLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+dayLeft+" "+top+";}}",style.rules.length);
});
$($(".main-content .month span")[0]).removeClass("current");
$(".month span").each(function(index,element){
$(element).css("animation","monthRun"+index+" 1s linear infinite");
style.insertRule("@keyframes monthRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+monthLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+monthLeft+" "+top+";}}",style.rules.length);
});
}, 7000);
更新每日
至于每秒每小时都差不多
$(".day").html("");
Time.days=updateDays(type,year,month,1);
Time.currentTime.day=getFirstDay(type);
$(".main-content .day").append("<span class='current'>"+Time.currentTime.day+Time.dayUnit+"</span>");
for (const key in Time.days) {
if (Time.days.hasOwnProperty(key)) {
const element = Time.days[key];
if(element!=Time.currentTime.day){
$(".main-content .day").append("<span>"+element+Time.dayUnit+"</span>");
}
}
}
$(".day span").each(function(index,element){
$(element).css("animation","day"+index+" 0.5s linear");
$(element).css("animation-fill-mode","forwards");
style.insertRule("@keyframes day"+index+"{0%{transform: rotateZ(0);transform-origin: -"+dayLeft+" "+top+";}100%{transform:rotateZ("+-(360/Time.days.length)*(index+1)+"deg);transform-origin: -"+dayLeft+" "+top+";}}",style.rules.length);
});
来源:https://juejin.cn/post/7102939166811357221
标签:JavaScript,动态,时钟
0
投稿
猜你喜欢
MySQL学习第五天 MySQL数据库基本操作
2024-01-28 19:17:58
Python绘图库Matplotlib的基本用法
2023-04-27 15:44:34
浅谈django 模型类使用save()方法的好处与注意事项
2021-05-17 10:43:59
python对绑定事件的鼠标、按键的判断实例
2021-05-20 03:12:58
MySQL数据库中CHAR与VARCHAR之争
2011-05-05 16:33:00
Python中IP地址处理IPy模块的方法
2023-05-19 05:21:25
asp 存储过程分页代码第1/2页
2011-04-03 10:39:00
泛域名设置问题
2008-03-25 10:03:00
基于Python计算圆周率pi代码实例
2021-03-06 05:13:17
浅谈MySQL之浅入深出页原理
2024-01-18 20:38:29
教你如何在WordPress发布文章时自定义文章作者名称
2023-11-12 07:47:11
php生成静态页面并实现预览功能
2023-11-15 08:37:11
MySql服务器系统变量和状态变量介绍
2024-01-20 19:37:15
MySQL 5.5 range分区增加删除处理的方法示例
2024-01-22 21:16:19
EasyASP v1.5发布(包含数据库操作类,原clsDbCtrl.asp)第1/2页
2011-04-08 10:40:00
CSS网页布局编码小技巧整理
2009-12-30 16:50:00
IE地址栏显示网站图标制作方法
2007-10-13 11:08:00
Python还能这么玩之用Python做个小游戏的外挂
2022-12-11 18:27:43
微信js-sdk 录音功能的示例代码
2024-04-22 13:04:45
Python-jenkins模块获取jobs的执行状态操作
2022-07-29 14:15:09