|
62 | 62 | background: black; |
63 | 63 | position: absolute; |
64 | 64 | top: 50%; |
| 65 | + transform-origin: 100%; |
| 66 | + transition: all 1s; |
| 67 | + transition-timing-function: ease-in-out; |
65 | 68 | } |
66 | 69 |
|
67 | 70 | </style> |
68 | 71 |
|
69 | 72 | <script> |
70 | | - |
71 | | - let hours = new Date().getHours() % 12; |
72 | | - let hourHand = document.getElementsByClassName('hour-hand')[0]; |
73 | | - hourHand.setAttribute('style', `transform: rotate(${90 + ((360 / 12) * hours)}deg); transform-origin: bottom right;`) |
74 | | - |
75 | | - let minutes = new Date().getMinutes(); |
76 | | - let minutesHand = document.getElementsByClassName('min-hand')[0]; |
77 | | - minutesHand.setAttribute('style', `transform: rotate(${90 + ((360 / (60)) * minutes)}deg); transform-origin: bottom right;`) |
78 | | - |
79 | | - let seconds = new Date().getSeconds(); |
80 | | - let secondsHand = document.getElementsByClassName('second-hand')[0]; |
81 | | - secondsHand.setAttribute('style', `transform: rotate(${90 + ((360 / (60)) * seconds)}deg); transform-origin: bottom right;`) |
82 | | - |
83 | | - setInterval(() => { |
| 73 | + let setTime = () => { |
84 | 74 | let seconds = new Date().getSeconds(); |
85 | 75 | let secondsHand = document.getElementsByClassName('second-hand')[0]; |
86 | | - secondsHand.setAttribute('style', `transform: rotate(${90 + ((360 / (60)) * seconds)}deg); transform-origin: bottom right;`) |
| 76 | + secondsHand.setAttribute('style', `transform: rotate(${90 + ((360 / (60)) * seconds)}deg); transform-origin: 100%;`) |
87 | 77 |
|
88 | 78 | let hours = new Date().getHours() % 12; |
89 | 79 | let hourHand = document.getElementsByClassName('hour-hand')[0]; |
90 | | - hourHand.setAttribute('style', `transform: rotate(${90 + ((360 / 12) * hours)}deg); transform-origin: bottom right;`) |
| 80 | + hourHand.setAttribute('style', `transform: rotate(${90 + ((360 / 12) * hours)}deg); transform-origin: 100%;`) |
91 | 81 |
|
92 | 82 | let minutes = new Date().getMinutes(); |
93 | 83 | let minutesHand = document.getElementsByClassName('min-hand')[0]; |
94 | | - minutesHand.setAttribute('style', `transform: rotate(${90 + ((360 / (60)) * minutes)}deg); transform-origin: bottom right;`) |
95 | | - }, 1000); |
| 84 | + minutesHand.setAttribute('style', `transform: rotate(${90 + ((360 / (60)) * minutes)}deg); transform-origin: 100%;`) |
| 85 | + } |
96 | 86 |
|
97 | | - // console.log('seconds', seconds); |
| 87 | + setInterval(() => {setTime()}, 1000); |
| 88 | + setTime(); |
98 | 89 |
|
99 | 90 |
|
100 | 91 | </script> |
|
0 commit comments