File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 6262 background : black;
6363 position : absolute;
6464 top : 50% ;
65+ transform-origin : 100% ; /*100% to make it in the origin*/
66+ transform : rotate (90deg );
67+ transition : all 0.05s ;
68+ transition-timing-function : cubic-bezier (0.1 , 2.7 , 0.58 , 1 );
69+
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 secondDegrees = ( seconds * 6 ) + 90 ;
84+ secondHand . style . transform = `rotate(${ secondDegrees } deg)` ;
7085
86+ const mins = now . getMinutes ( ) ;
87+ const minDegrees = ( mins * 6 ) + 90 ;
88+ minHand . style . transform = `rotate(${ minDegrees } deg)` ;
89+
90+ const hours = now . getHours ( ) ;
91+ const hourDegrees = ( hours * 30 ) + 90 ;
92+ hourHand . style . transform = `rotate(${ hourDegrees } deg)` ;
93+ }
94+ setInterval ( setDate , 1000 ) ;
7195
7296 </ script >
7397</ body >
You can’t perform that action at this time.
0 commit comments