-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
29 lines (23 loc) · 949 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
27
28
29
const secondsHand=document.querySelector('.sec-hand');
const minutesHand = document.querySelector('.min-hand');
const hourHand = document.querySelector('.hour-hand');
const getTime = () => {
const now = new Date();
const seconds = now.getSeconds();
const minutes = now.getMinutes();
const hours = now.getHours();
// console.log(minutes);
console.log(hours);
if(seconds === 0 || minutes === 0 || hours === 0){
secondsHand.style.transition = `none`;
minutesHand.style.transition = `none`;
hourHand.style.transition = `none`;
}
const secondsDegree = (seconds/60)*360 + 90;
const minutesDegree = (minutes/60)*360 + 90;
const hoursDegree = (hours/12)*360 + 90;
secondsHand.style.transform = `rotate(${secondsDegree}deg)`;
minutesHand.style.transform = `rotate(${minutesDegree}deg)`;
hourHand.style.transform = `rotate(${hoursDegree}deg)`;
}
setInterval(getTime, 1000);