File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-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.05s ;
69+ transition-timing-function : cubic-bezier (0.1 , 2.7 , 0.58 , 1 );
6670 }
6771
6872 </ style >
6973
7074 < script >
75+ const secondHand = document . querySelector ( '.second-hand' ) ;
76+ const minHand = document . querySelector ( '.min-hand' ) ;
77+ const hourHand = document . querySelector ( '.hour-hand' ) ;
7178
79+ function setDate ( ) {
80+ const now = new Date ( ) ;
81+ const seconds = now . getSeconds ( ) ;
82+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
83+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
7284
85+ const minutes = now . getMinutes ( ) ;
86+ const minutesDegrees = ( ( minutes / 60 ) * 360 ) + 90 ;
87+ minHand . style . transform = `rotate(${ minutesDegrees } deg)` ;
88+
89+ const hours = now . getHours ( ) ;
90+ const hoursDegrees = ( ( hours / 12 ) * 360 ) + 90 ;
91+ hourHand . style . transform = `rotate(${ hoursDegrees } deg)` ;
92+
93+ console . log ( hours , minutes , seconds ) ;
94+ }
95+ setInterval ( setDate , 1000 )
7396 </ script >
7497</ body >
7598</ html >
You can’t perform that action at this time.
0 commit comments