- Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
21 lines (17 loc) · 704 Bytes
/
Copy pathscript.js
File metadata and controls
21 lines (17 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
setInterval(setClock,1000)
consthourHand=document.querySelector('[data-hour-hand]')
constminuteHand=document.querySelector('[data-minute-hand]')
constsecondHand=document.querySelector('[data-second-hand]')
functionsetClock(){
constcurrentDate=newDate()
constsecondsRatio=currentDate.getSeconds()/60
constminutesRatio=(secondsRatio+currentDate.getMinutes())/60
consthoursRatio=(minutesRatio+currentDate.getHours())/12
setRotation(secondHand,secondsRatio)
setRotation(minuteHand,minutesRatio)
setRotation(hourHand,hoursRatio)
}
functionsetRotation(element,rotationRatio){
element.style.setProperty('--rotation',rotationRatio*360)
}
setClock()