diff --git a/Beautiful JS Clock/index.html b/Beautiful JS Clock/index.html index 45593d9f..b5fd54ed 100644 --- a/Beautiful JS Clock/index.html +++ b/Beautiful JS Clock/index.html @@ -15,23 +15,7 @@
- + \ No newline at end of file diff --git a/Beautiful JS Clock/main.js b/Beautiful JS Clock/main.js new file mode 100644 index 00000000..cc00e580 --- /dev/null +++ b/Beautiful JS Clock/main.js @@ -0,0 +1,15 @@ +function runClock() { + let currentTime = new Date(); + let secondRotate = (currentTime.getSeconds() / 60) * 360; + let minuteRotate = (currentTime.getMinutes() / 60) * 360; + let hourRotate = ((currentTime.getHours() + (currentTime.getMinutes() / 60)) / 12) * 360; + + let secondHand = document.querySelector(".secondHand"); + let minuteHand = document.querySelector(".minuteHand"); + let hourHand = document.querySelector(".hourHand"); + secondHand.style.transform = `rotate(${secondRotate}deg) translateY(-30%)`; + minuteHand.style.transform = `rotate(${minuteRotate}deg) translateY(-50%)`; + hourHand.style.transform = `rotate(${hourRotate}deg) translateY(-50%)`; +} + +setInterval(runClock, 1000); \ No newline at end of file