File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6262 background : black;
6363 position : absolute;
6464 top : 50% ;
65+
66+ transform-origin : 100% ;
67+ transform : rotate (90deg );
68+ transition : all 0.5s ;
69+ transition-timing-function : cubic-bezier (0.1 , 2.7 , 0.58 , 1 );
6570 }
6671
6772 </ style >
6873
6974 < 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 secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
84+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
85+
86+ const min = now . getMinutes ( ) ;
87+ const minDegrees = ( ( min / 60 ) * 360 ) + 90 ;
88+ minHand . style . transform = `rotate(${ minDegrees } deg)` ;
89+
90+ const hour = now . getHours ( ) ;
91+ const hourDegrees = ( ( min / 12 ) * 360 ) + 90 ;
92+ hourHand . style . transform = `rotate(${ hourDegrees } deg)` ;
93+ }
7094
95+ //tells how often setDate should run in milliseconds
96+ setInterval ( setDate , 1000 ) ;
7197
7298 </ script >
7399</ body >
You can’t perform that action at this time.
0 commit comments