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