File tree 1 file changed +24
-1
lines changed
1 file changed +24
-1
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 "> </ div >
14
+ < div class ="hand second-hand " style =" transform: rotate(-90); " > </ div >
15
15
</ div >
16
16
</ div >
17
17
53
53
width : 100% ;
54
54
height : 100% ;
55
55
transform : translateY (-3px ); /* account for the height of the clock hands */
56
+ transition : all 0.05s ;
57
+ transition-timing-function : cubic-bezier (0.1 , 2.7 , 0.58 , 1 );
56
58
}
57
59
58
60
.hand {
61
63
background : black;
62
64
position : absolute;
63
65
top : 50% ;
66
+ transform-origin : 100 ;
67
+ transform : rotate (90deg );
64
68
}
65
69
66
70
</ style >
67
71
68
72
< script >
73
+ const secondHand = document . querySelector ( '.second-hand' ) ;
74
+ const minsHand = 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 mins = now . getMinutes ( ) ;
84
+ const minDegrees = ( ( mins / 60 ) * 360 ) + 90 ;
85
+ minsHand . style . transform = `rotate(${ minDegrees } deg)` ;
86
+
87
+ const hour = now . getHours ( ) ;
88
+ const hourDegrees = ( ( hour / 12 ) * 360 ) + 90 ;
89
+ hoursHand . style . transform = `rotate(${ hourDegrees } deg)` ;
90
+ }
91
+
92
+ setInterval ( setDate , 1000 ) ;
70
93
71
94
</ script >
72
95
</ body >
You can’t perform that action at this time.
0 commit comments