Skip to content

Commit c8d0a02

Browse files
committed
Finished Day 2
1 parent e3b4261 commit c8d0a02

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,39 @@
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, 2.9, 0.99, 1.01);
6468
}
6569

6670
</style>
6771

6872
<script>
73+
const hoursHand = document.querySelector('.hour-hand');
74+
const minutesHand = document.querySelector('.min-hand');
75+
const secondHand = document.querySelector('.second-hand');
6976

77+
function setDate() {
78+
const now = new Date();
7079

80+
const hours = now.getHours();
81+
console.log(`hours: ${hours}`);
82+
const hoursDegrees = ((hours % 12)/12 * 360 + 90);
83+
hoursHand.style.transform = `rotate(${hoursDegrees}deg)`;
84+
85+
const minutes = now.getMinutes();
86+
console.log(`minutes: ${minutes}`);
87+
const minutesDegrees = ((minutes)/60 * 360 + 90);
88+
minutesHand.style.transform = `rotate(${minutesDegrees}deg)`;
89+
90+
const seconds = now.getSeconds();
91+
console.log(`seconds: ${seconds}`);
92+
const secondsDegrees = ((seconds/60) * 360 + 90);
93+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
94+
}
95+
96+
setInterval(setDate, 1000);
7197
</script>
7298
</body>
7399
</html>

0 commit comments

Comments
 (0)