File tree Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change 6464 transform-origin : 100% ;
6565 transform : rotate (90deg );
6666 transition : all 0.05s ;
67- transition-timing-function : ease-in-out ;
67+ transition-timing-function : cubic-bezier ( 0.1 , 2.7 , 0.58 , 1 ) ;
6868 }
69-
7069 </ style >
7170
7271 < script >
73- function setDate ( ) {
74- const now = new Date ( ) ;
75- const seconds = now . getSeconds ( ) ;
76- const secondsDegrees = ( ( seconds / 60 ) * 360 ) ;
7772 const secondHand = document . querySelector ( '.second-hand' ) ;
73+ const minuteHand = document . querySelector ( '.min-hand' ) ;
74+ const hourHand = document . querySelector ( '.hour-hand' ) ;
75+
76+ function setDate ( ) {
77+ const now = new Date ( ) ;
78+ const seconds = now . getSeconds ( ) ;
79+ const minutes = now . getMinutes ( ) ;
80+ const hours = now . getHours ( ) ;
7881
79- console . log ( seconds ) ;
80- }
82+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
83+ const minutesDegrees = ( ( minutes / 60 ) * 360 ) + 90 ;
84+ const hoursDegrees = ( ( hours / 12 ) * 360 ) + 90 ;
85+
86+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
87+ minuteHand . style . transform = `rotate(${ minutesDegrees } deg)` ;
88+ hourHand . style . transform = `rotate(${ hoursDegrees } deg)` ;
89+ }
90+ setInterval ( setDate , 1000 ) ;
8191
82- setInterval ( setDate , 1000 ) ;
92+ setDate ( ) ;
8393
8494 </ script >
8595</ body >
You can’t perform that action at this time.
0 commit comments