-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (17 loc) · 705 Bytes
/
app.js
File metadata and controls
29 lines (17 loc) · 705 Bytes
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
27
28
29
setInterval(setClock,1000)
const hourHand = document.querySelector('[data-hour-hand]')
const minuteHand = document.querySelector('[data-minute-hand]')
const secondHand = document.querySelector('[data-second-hand]')
function setClock(){
const currentDate=new Date()
const secondsRatio=currentDate.getSeconds()/60
const minutesRatio= (secondsRatio + currentDate.getMinutes())/60
const hoursRatio=(minutesRatio +currentDate.getHours())/12
setRotation(secondHand,secondsRatio)
setRotation(minuteHand,minutesRatio)
setRotation(hourHand,hoursRatio)
}
function setRotation(element,rotationRatio){
element.style.setProperty('--rotation',rotationRatio*360)
}
setClock()