File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 61
61
background : black;
62
62
position : absolute;
63
63
top : 50% ;
64
+ transform-origin : 100% ;
65
+ transform : rotate (90deg );
66
+ transition : all 0.05s ;
67
+ transition-timing-function : cubic-bezier (0.42 , 0 , 0 , 2.85 );
64
68
}
65
69
66
70
</ style >
67
71
68
72
< script >
73
+ const secondHand = document . querySelector ( '.second-hand' ) ;
74
+ const minuteHand = document . querySelector ( '.min-hand' ) ;
75
+ const hourHand = document . querySelector ( '.hour-hand' ) ;
69
76
77
+ function setTransform ( element , deg ) {
78
+ element . style . transform = `rotate(${ deg } deg)` ;
79
+ }
80
+
81
+ function setDate ( ) {
82
+ const date = new Date ( )
83
+
84
+ const second = date . getSeconds ( ) ;
85
+ const secDeg = ( ( second / 60 ) * 360 ) + 90 ;
86
+ setTransform ( secondHand , secDeg ) ;
87
+
88
+ const minute = date . getMinutes ( ) ;
89
+ const minDeg = ( ( minute / 60 ) * 360 ) + 90 ;
90
+ setTransform ( minuteHand , minDeg ) ;
91
+
92
+ const hour = date . getHours ( ) ;
93
+ const hourDeg = ( ( hour / 12 ) * 360 ) + 90 ;
94
+ setTransform ( hourHand , hourDeg ) ;
95
+ }
70
96
97
+ setInterval ( setDate , 1000 ) ;
71
98
</ script >
72
99
</ body >
73
100
</ html >
You can’t perform that action at this time.
0 commit comments