File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Expand file tree Collapse file tree 2 files changed +39
-3
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% ; /* moves origin of skew/ animation along x-axis*/
65+ transform : rotate (90deg );
66+ transition : all 0.5s ;
67+ transition-timing-function : cubic-bezier (0.1 , 2.7 , 0.58 , 1 );
6468 }
6569
66- </ style >
70+ .hour-hand {
71+ height : 10px ;
72+ width : 40% ;
73+ transform-origin : 110% ;
74+ }
6775
68- < script >
76+ .minute-hand {
77+ height : 5px ;
78+ }
6979
80+ .second-hand {
81+ height : 2px ;
82+ background : white;
83+ }
84+
85+
86+ </ style >
7087
71- </ script >
88+ < script type =" text/javascript " src =" js/entry.js " > < /script >
7289</ body >
7390</ html >
Original file line number Diff line number Diff line change 1+ const secondHand = document . querySelector ( '.second-hand' ) ;
2+ const hourHand = document . querySelector ( '.hour-hand' ) ;
3+ const minuteHand = document . querySelector ( '.min-hand' ) ;
4+
5+
6+ function setDate ( ) {
7+ const now = new Date ( ) ; // built into JS. Represents a single moment in time.
8+ const seconds = now . getSeconds ( ) ;
9+ const minutes = now . getMinutes ( ) ;
10+ const hours = now . getHours ( ) ;
11+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
12+ const minutesDegrees = ( ( minutes / 60 ) * 360 ) + 90 ;
13+ const hoursDegrees = ( ( hours / 12 ) * 360 ) + 90 ;
14+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
15+ hourHand . style . transform = `rotate(${ hoursDegrees } deg)` ;
16+ minuteHand . style . transform = `rotate(${ minutesDegrees } deg)` ;
17+ }
18+
19+ setInterval ( setDate , 1000 ) ;
You can’t perform that action at this time.
0 commit comments