File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 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.1 , 2.7 , 0.58 , 1 );
64
68
}
65
69
66
70
</ style >
67
71
68
72
< script >
69
73
74
+ const secondHand = document . querySelector ( '.second-hand' ) ;
75
+ const minuteHand = document . querySelector ( '.min-hand' ) ;
76
+ const hourHand = document . querySelector ( '.hour-hand' ) ;
77
+
78
+
79
+ function setDate ( ) {
80
+ const now = new Date ( ) ;
81
+ const seconds = now . getSeconds ( ) ;
82
+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
83
+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
84
+
85
+ const minutes = now . getMinutes ( ) ;
86
+ const minutesDegrees = ( ( minutes / 60 ) * 360 ) + 90 ;
87
+ minuteHand . style . transform = `rotate(${ minutesDegrees } deg)` ;
88
+
89
+ const hours = now . getHours ( ) ;
90
+ const hoursDegrees = ( ( hours / 12 ) * 360 ) + 90 ;
91
+ hourHand . style . transform = `rotate(${ hoursDegrees } deg)` ;
92
+
93
+ // console.log(seconds);
94
+ }
95
+
96
+ setInterval ( setDate , 1000 ) ;
70
97
71
98
</ script >
72
99
</ body >
You can’t perform that action at this time.
0 commit comments