-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
33 lines (30 loc) · 1.06 KB
/
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
30
31
32
33
let secHand = document.querySelector('.second-hand')
let minHand = document.querySelector('.min-hand')
let hourHand = document.querySelector('.hour-hand')
function tick() {
// console.log('tick')
let now = new Date()
let sec = now.getSeconds()
let mins = now.getMinutes()
let hour = now.getHours()
console.log(sec)
let secDeg = 90 + (360 / 60) * sec
let minDeg = 90 + 6 * mins + 0.1 * sec
let hourDeg = 90 + 30 * hour + 0.5 * mins
if (secDeg === 90)
secHand.style.transition = 'all 0s';
else
secHand.style.transition = 'all 0.05s';
if (minDeg === 90)
minHand.style.transition = 'all 0s';
else
minHand.style.transition = 'all 0.1s';
secHand.style.transform = `rotate(${secDeg}deg)`
minHand.style.transform = `rotate(${minDeg}deg)`
hourHand.style.transform = `rotate(${hourDeg}deg) scaleX(0.7)`;
}
function test() {
console.log('test')
hourHand.style.transform = "rotate(450deg)"
}
setInterval(tick, 1000)