File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change 6161background : black;
6262position : absolute;
6363top : 50% ;
64+ transform-origin : 100% ;
65+ transform : rotate (90deg );
66+ transition : all 0.5s
67+ transition-timing-function: cubic-bezier (1 , 2.99 , 0.58 , 1 );
68+
6469 }
6570
6671</ style >
67-
6872< script >
69-
73+ setInterval ( tick , 1000 )
74+ function tick ( ) {
75+ const date = new Date ( ) ;
76+ const seconds = date . getSeconds ( ) ;
77+ secTick ( date . getSeconds ( ) )
78+ minuteTick ( date . getMinutes ( ) )
79+ hourTick ( date . getHours ( ) )
80+ }
81+ function secTick ( sec ) {
82+ const secondsDegrees = sec * 6 ;
83+ const handSec = document . querySelector ( '.hand.second-hand' ) ;
84+ handSec . style . transform = `rotate(${ secondsDegrees } deg)` ;
85+ }
86+ function minuteTick ( min ) {
87+ const minDegrees = min * 6 ;
88+ const handMin = document . querySelector ( '.hand.min-hand' ) ;
89+ handMin . style . transform = `rotate(${ minDegrees } deg)` ;
90+ }
91+ function hourTick ( hour ) {
92+ const hourDegrees = hour * 30 ;
93+ const handHour = document . querySelector ( '.hand.hour-hand' ) ;
94+ handHour . style . transform = `rotate(${ hourDegrees } deg)` ;
95+ }
7096
7197</ script >
7298</ body >
You can’t perform that action at this time.
0 commit comments