forked from wesbos/JavaScript30
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
20 lines (17 loc) · 703 Bytes
/
app.js
File metadata and controls
20 lines (17 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const secondHand = document.querySelector('.hour-hand'),
minuteHand = document.querySelector('.min-hand'),
hourHand = document.querySelector('.second-hand');
function setDate() {
const now = new Date(),
seconds = now.getSeconds(),
// +90 offsets default set in CSS
secondDeg = ((seconds/60) * 360) + 90,
minutes = now.getMinutes(),
minuteDeg = ((minutes/60) * 360) + 90,
hours = now.getHours(),
hourDeg = ((hours/12) * 360) + 90;
secondHand.style.transform = `rotate(${secondDeg}deg)`;
minuteHand.style.transform = `rotate(${minuteDeg}deg)`;
hourHand.style.transform = `rotate(${hourDeg}deg)`;
}
setInterval(setDate, 1000);