|
61 | 61 | background:black; |
62 | 62 | position: absolute; |
63 | 63 | top:50%; |
64 | | - transform-origin: 100%; |
| 64 | + transform-origin:right; /*same as transform-origin:100%. Use values over 100% to transfrom about a point off the object*/ |
65 | 65 | transform: rotate(90deg); |
66 | 66 | transition: all 0.05s; |
67 | | - transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1); |
| 67 | + transition-timing-function: cubic-bezier(0, 2.7, 0.58, 1); |
68 | 68 | } |
69 | | -</style> |
70 | 69 |
|
71 | | -<script> |
72 | | - const secondHand = document.querySelector('.second-hand'); |
73 | | - const minsHand = document.querySelector('.min-hand'); |
74 | | - const hourHand = document.querySelector('.hour-hand'); |
| 70 | + </style> |
75 | 71 |
|
76 | | - function setDate() { |
77 | | - const now = new Date(); |
| 72 | + <script> |
78 | 73 |
|
79 | | - const seconds = now.getSeconds(); |
80 | | - const secondsDegrees = ((seconds / 60) * 360) + 90; |
81 | | - secondHand.style.transform = `rotate(${secondsDegrees}deg)`; |
| 74 | + const secondHand = document.querySelector('.second-hand'); |
| 75 | + const minuteHand = document.querySelector('.min-hand'); |
| 76 | + const hourHand = document.querySelector('.hour-hand'); |
82 | 77 |
|
83 | | - const mins = now.getMinutes(); |
84 | | - const minsDegrees = ((mins / 60) * 360) + 90; |
85 | | - minsHand.style.transform = `rotate(${minsDegrees}deg)`; |
86 | | - |
87 | | - const hour = now.getMinutes(); |
88 | | - const hourDegrees = ((mins / 12) * 360) + 90; |
89 | | - hourHand.style.transform = `rotate(${hourDegrees}deg)`; |
90 | | - } |
| 78 | + function setDate() { |
| 79 | + const now = new Date(); |
| 80 | + const seconds = now.getSeconds(); |
| 81 | + const minutes = now.getMinutes(); |
| 82 | + const hours = now.getHours(); |
| 83 | + const secondsDegrees = (seconds * 6) + 90 /*(seconds/60 * 360) = seconds * 6)*/ |
| 84 | + const minutesDegrees = (minutes * 6) + 90 |
| 85 | + const hoursDegrees = (hours * 30) + 90 /*360/12 = 30 */ |
| 86 | + secondHand.style.transform = `rotate(${secondsDegrees}deg)`; |
| 87 | + minuteHand.style.transform = `rotate(${minutesDegrees}deg)`; |
| 88 | + hourHand.style.transform = `rotate(${hoursDegrees}deg)`; |
| 89 | + } |
91 | 90 |
|
92 | | - setInterval(setDate, 1000); |
| 91 | + setInterval(setDate, 1000); /*built in function that runs a function at a given period |
| 92 | + document.querySelector(`.second-hand');*/ |
93 | 93 |
|
94 | | -</script> |
| 94 | + </script> |
95 | 95 | </body> |
96 | 96 | </html> |
0 commit comments