File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6161 background : black;
6262 position : absolute;
6363 top : 50% ;
64+ transform-origin : 100% ;
65+ transform : rotate (90deg );
66+ transition : all 0.05s ;
67+ transition-timing-function : ease-in-out;
6468 }
6569
6670 </ style >
6771
6872 < script >
73+ const secondHand = document . querySelector ( '.second-hand' )
74+ const minHand = document . querySelector ( '.min-hand' )
75+ const hourHand = document . querySelector ( '.hour-hand' )
76+
77+ function setDate ( ) {
78+ const now = new Date ( ) ;
79+ const seconds = now . getSeconds ( ) ;
80+ const min = now . getMinutes ( ) ;
81+ const hour = now . getHours ( ) ;
82+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
83+ const minDegrees = ( ( min / 60 ) * 360 ) + 90 ;
84+ const hourDegrees = ( ( hour / 12 ) * 360 ) + 90 ;
85+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
86+ minHand . style . transform = `rotate(${ minDegrees } deg)` ;
87+ hourHand . style . transform = `rotate(${ hourDegrees } deg)` ;
88+ }
89+
90+
91+
92+ setInterval ( setDate , 1000 )
6993
7094
7195 </ script >
You can’t perform that action at this time.
0 commit comments