forked from wesbos/JavaScript30
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (17 loc) · 699 Bytes
/
script.js
File metadata and controls
23 lines (17 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const secondHand = document.querySelector('.second-hand');
const minuteHand = document.querySelector('.min-hand');
const hourHand = document.querySelector('.hour-hand');
function update() {
const date = new Date();
const seconds = date.getSeconds();
const minutes = date.getMinutes() + seconds / 60;
const hours = date.getHours() + minutes / 60;
secDeg = 360 * (seconds / 60) + 90;
minDeg = 360 * (minutes / 60) + 90;
hrDeg = 360 * (hours / 12) + 90;
console.log(hrDeg, minDeg, secDeg);
secondHand.style.transform = `rotate(${secDeg}deg)`;
minuteHand.style.transform = `rotate(${minDeg}deg)`;
hourHand.style.transform = `rotate(${hrDeg}deg)`;
}
setInterval(update, 1000);