|
64 | 64 | transform-origin: 100%; |
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.41, 1.99, 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 | + .second-hand { |
| 71 | + height: 4px; |
| 72 | + } |
| 73 | + |
| 74 | + .hour-hand { |
| 75 | + height: 8px; |
| 76 | + } |
| 77 | + </style> |
75 | 78 |
|
76 | | - function setDate() { |
77 | | - const now = new Date(); |
| 79 | + <script> |
| 80 | + const secondHand = document.querySelector('.second-hand'); |
| 81 | + const minuteHand = document.querySelector('.min-hand'); |
| 82 | + const hourHand = document.querySelector('.hour-hand'); |
78 | 83 |
|
79 | | - const seconds = now.getSeconds(); |
80 | | - const secondsDegrees = ((seconds / 60) * 360) + 90; |
81 | | - secondHand.style.transform = `rotate(${secondsDegrees}deg)`; |
| 84 | + function setDate() { |
| 85 | + const now = new Date(); |
82 | 86 |
|
83 | | - const mins = now.getMinutes(); |
84 | | - const minsDegrees = ((mins / 60) * 360) + 90; |
85 | | - minsHand.style.transform = `rotate(${minsDegrees}deg)`; |
| 87 | + const seconds = now.getSeconds(); |
| 88 | + const secondsDegrees = ((seconds / 60) * 360) + 90; |
| 89 | + secondHand.style.transform = `rotate(${secondsDegrees}deg)`; |
86 | 90 |
|
87 | | - const hour = now.getMinutes(); |
88 | | - const hourDegrees = ((mins / 12) * 360) + 90; |
89 | | - hourHand.style.transform = `rotate(${hourDegrees}deg)`; |
90 | | - } |
| 91 | + const minutes = now.getMinutes(); |
| 92 | + const minutesDegrees = ((minutes / 60) * 360) + 90; |
| 93 | + minuteHand.style.transform = `rotate(${minutesDegrees}deg)`; |
91 | 94 |
|
92 | | - setInterval(setDate, 1000); |
| 95 | + const hours = now.getHours(); |
| 96 | + const hoursDegrees = (((hours + (minutes / 60)) / 12) * 360) + 90; |
| 97 | + hourHand.style.transform = `rotate(${hoursDegrees}deg)`; |
| 98 | + } |
93 | 99 |
|
94 | | -</script> |
| 100 | + setInterval(setDate, 1000); |
| 101 | + </script> |
95 | 102 | </body> |
96 | 103 | </html> |
0 commit comments