Skip to content

Commit 0623aa0

Browse files
committed
second task finished
1 parent fce71fa commit 0623aa0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,36 @@
6363
background: black;
6464
position: absolute;
6565
top: 50%;
66+
transform-origin: 100%;
67+
transform: rotate(90deg);
68+
transition: all 0.05s;
69+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
6670
}
6771

6872
</style>
6973

7074
<script>
75+
const secondHand = document.querySelector('.second-hand');
76+
const minHand = document.querySelector('.min-hand');
77+
const hourHand = document.querySelector('.hour-hand');
7178

79+
function setDate() {
80+
const now = new Date();
81+
const seconds = now.getSeconds();
82+
const secondsDegrees = ((seconds / 60) * 360) + 90;
83+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
7284

85+
const minutes = now.getMinutes();
86+
const minutesDegrees = ((minutes / 60) * 360) + 90;
87+
minHand.style.transform = `rotate(${minutesDegrees}deg)`;
88+
89+
const hours = now.getHours();
90+
const hoursDegrees = ((hours / 12) * 360) + 90;
91+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
92+
93+
console.log(hours, minutes, seconds);
94+
}
95+
setInterval(setDate, 1000)
7396
</script>
7497
</body>
7598
</html>

0 commit comments

Comments
 (0)