Skip to content

Commit c8f6841

Browse files
committed
clock done
1 parent eb88dc8 commit c8f6841

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

02 - JS + CSS Clock/index-START.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,34 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
transition: all 0.05s;
67+
transition-timing-function: cubic-bezier(0.14, 2.49, 1, 1.02);
6468
}
6569

6670
</style>
6771

6872
<script>
73+
const secondHand = document.querySelector('.second-hand');
74+
const minuteHand = document.querySelector('.min-hand');
75+
const hourHand = document.querySelector('.hour-hand');
76+
function setDate() {
77+
const now = new Date();
78+
const seconds = now.getSeconds();
79+
const secondsDegrees = ((seconds / 60) * 360) + 90;
6980

81+
const minutes = now.getMinutes();
82+
const minuteDegrees = ((minutes / 60) * 360) + 90;
83+
84+
const hourDegrees = ((minutes / 12) * 360) + 90;
85+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
86+
minuteHand.style.transform = `rotate(${minuteDegrees}deg)`;
87+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
88+
console.log(seconds);
89+
}
90+
91+
setInterval(setDate, 1000)
7092

7193
</script>
7294
</body>

0 commit comments

Comments
 (0)