Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions Beautiful JS Clock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,7 @@
<div class="minuteHand"></div>
<div class="secondHand"></div>
</div>
<script>
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);
</script>
<script type="text/javascript" src="main.js"></script>
</body>

</html>
15 changes: 15 additions & 0 deletions Beautiful JS Clock/main.js
Original file line number Diff line number Diff line change
@@ -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);