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+ transform-origin : 100% ;
66+ transform : rotate (90deg );
67+ transition : all 0.05s ;
68+ transition-timing-function : cubic-bezier (0.1 , 2.7 , 0.58 , 1 );
6569 }
6670
6771 </ style >
6872
6973 < script >
74+ const secondHand = document . querySelector ( '.second-hand' ) ;
75+ const minsHand = document . querySelector ( '.min-hand' ) ;
76+ const hourHand = document . querySelector ( '.hour-hand' ) ;
7077
78+ function setDate ( ) {
79+ const now = new Date ( ) ;
7180
81+ // Seconds
82+ const seconds = now . getSeconds ( ) ;
83+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
84+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
85+
86+ // Minutes
87+ const mins = now . getMinutes ( ) ;
88+ const minsDegrees = ( ( mins / 60 ) * 360 ) + 90 ;
89+ minsHand . style . transform = `rotate(${ minsDegrees } deg)` ;
90+
91+ // hours
92+ const hours = now . getHours ( ) ;
93+ const hoursDegrees = ( ( hours / 12 ) * 360 ) + 90 ;
94+ hourHand . style . transform = `rotate(${ hoursDegrees } deg)` ;
95+ }
96+
97+ setInterval ( setDate , 1000 ) ;
7298 </ script >
7399</ body >
74100</ html >
You can’t perform that action at this time.
0 commit comments