File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed 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 : cubic-bezier (0.42 , 0 , 0.25 , 1.85 );
6468 }
6569
6670 </ style >
6771
68- < script >
72+ < script >
73+ const secondHand = document . querySelector ( '.second-hand' ) ,
74+ minuteHand = document . querySelector ( '.min-hand' ) ,
75+ hourHand = document . querySelector ( '.hour-hand' )
6976
77+ function setTime ( ) {
78+ const now = new Date ( ) ,
79+ seconds = getRotation ( now . getSeconds ( ) , 60 ) ,
80+ minutes = getRotation ( now . getMinutes ( ) , 60 ) ,
81+ hours = getRotation ( now . getHours ( ) , 12 )
82+
83+ secondHand . style . transform = `rotate(${ seconds } deg)`
84+ minuteHand . style . transform = `rotate(${ minutes } deg)`
85+ hourHand . style . transform = `rotate(${ hours } deg)`
86+ }
7087
71- </ script >
88+ function getRotation ( timeValue , scale ) {
89+ return ( timeValue / scale * 360 ) + 90
90+ }
91+
92+ setInterval ( setTime , 1000 )
93+ </ script >
7294</ body >
7395</ html >
You can’t perform that action at this time.
0 commit comments