File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 62
62
background : black;
63
63
position : absolute;
64
64
top : 50% ;
65
+ transform-origin : 100% ; /*100% to make it in the origin*/
66
+ transform : rotate (90deg );
67
+ transition : all 0.05s ;
68
+ transition-timing-function : cubic-bezier (0.1 , 2.7 , 0.58 , 1 );
69
+
65
70
}
66
71
67
72
</ style >
68
73
69
74
< script >
75
+ const secondHand = document . querySelector ( '.second-hand' ) ;
76
+ const minHand = document . querySelector ( '.min-hand' ) ;
77
+ const hourHand = document . querySelector ( '.hour-hand' ) ;
78
+
79
+ function setDate ( ) {
80
+ const now = new Date ( ) ;
81
+
82
+ const seconds = now . getSeconds ( ) ;
83
+ const secondDegrees = ( seconds * 6 ) + 90 ;
84
+ secondHand . style . transform = `rotate(${ secondDegrees } deg)` ;
70
85
86
+ const mins = now . getMinutes ( ) ;
87
+ const minDegrees = ( mins * 6 ) + 90 ;
88
+ minHand . style . transform = `rotate(${ minDegrees } deg)` ;
89
+
90
+ const hours = now . getHours ( ) ;
91
+ const hourDegrees = ( hours * 30 ) + 90 ;
92
+ hourHand . style . transform = `rotate(${ hourDegrees } deg)` ;
93
+ }
94
+ setInterval ( setDate , 1000 ) ;
71
95
72
96
</ script >
73
97
</ body >
You can’t perform that action at this time.
0 commit comments