File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 6363 background : black;
6464 position : absolute;
6565 top : 50% ;
66+ transform-origin : 100% ;
67+ transform : rotate (90deg );
68+ transition : all 0.2s ;
69+ transition-timing-function : cubic-bezier (0.16 , 2.29 , 0.74 , 0.75 );
6670 }
6771
6872 </ style >
6973
7074 < script >
7175
76+ const secondHand = document . querySelector ( '.second-hand' ) ;
77+ const minuteHand = document . querySelector ( '.min-hand' ) ;
78+ const hourHand = document . querySelector ( '.hour-hand' ) ;
79+
80+ function setDate ( ) {
81+ const now = new Date ( ) ;
82+
83+ const seconds = now . getSeconds ( ) ;
84+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
85+
86+ const minutes = now . getMinutes ( ) ;
87+ const minutesDegrees = ( ( minutes / 60 ) * 360 ) + ( ( seconds / 60 ) * 6 ) + 90 ;
88+
89+ const hour = now . getHours ( ) ;
90+ const hourDegrees = ( ( hour / 12 ) * 360 ) + ( ( minutes / 60 ) * 30 ) + 90 ;
91+
92+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)`
93+ minuteHand . style . transform = `rotate(${ minutesDegrees } deg)`
94+ hourHand . style . transform = `rotate(${ hourDegrees } deg)` ;
95+
96+ console . log ( seconds )
97+
98+
99+ }
100+
101+ setInterval ( setDate , 1000 ) ;
72102
73103 </ script >
74104</ body >
You can’t perform that action at this time.
0 commit comments