File tree 1 file changed +22
-2
lines changed
1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 11
11
< div class ="clock-face ">
12
12
< div class ="hand hour-hand "> </ div >
13
13
< div class ="hand min-hand "> </ div >
14
- < div class ="hand second-hand " style ="
15
- transform: rotate(-50deg); "> </ div >
14
+ < div class ="hand second-hand "> </ div >
16
15
</ div >
17
16
</ div >
18
17
76
75
</ style >
77
76
78
77
< script >
78
+ const secondHand = document . querySelector ( '.second-hand' ) ;
79
+ const hourHand = document . querySelector ( '.hour-hand' ) ;
80
+ const minuteHand = document . querySelector ( '.min-hand' ) ;
81
+
82
+ function setDate ( ) {
83
+ const now = new Date ( ) ;
84
+ const seconds = now . getSeconds ( ) ;
85
+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
86
+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
87
+
88
+ const mins = now . getMinutes ( ) ;
89
+ const minsDegrees = ( ( mins / 60 ) * 360 ) + 90 ;
90
+ minuteHand . style . transform = `rotate(${ minsDegrees } deg)`
91
+
92
+ const hour = now . getHours ( ) ;
93
+ const hourDegrees = ( ( hour / 12 ) * 360 ) + 90 ;
94
+ hourHand . style . transform = `rotate(${ hourDegrees } deg)`
95
+ console . log ( seconds ) ;
96
+ }
97
+
98
+ setInterval ( setDate , 1000 ) ;
79
99
</ script >
80
100
</ body >
81
101
</ html >
You can’t perform that action at this time.
0 commit comments