-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
26 lines (19 loc) · 956 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const secondhand = document.getElementById("second")
const minutehand = document.getElementById("minute")
const hourhand = document.getElementById("hour")
// --------------------------------------------------------------------------------------------------
function clocktick() {
const date = new Date();
const seconds = date.getSeconds() / 60;
const minutes = (seconds + date.getMinutes()) / 60;
const hours = (minutes + date.getHours()) / 12;
rotateclockhand(secondhand, seconds);
rotateclockhand(minutehand, minutes);
rotateclockhand(hourhand, hours);
}
// --------------------------------------------------------------------------------------------------
function rotateclockhand(element, rotation) {
element.style.setProperty("--rotate", rotation * 360);
}
// --------------------------------------------------------------------------------------------------
setInterval(clocktick, 1000)