Skip to content
This repository was archived by the owner on Feb 13, 2022. It is now read-only.

Commit fb5b0eb

Browse files
committed
solution wesbos#2
1 parent 5c16b1f commit fb5b0eb

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +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.1, 2.7, 0.58, 1);
6468
}
65-
6669
</style>
6770

6871
<script>
72+
const hoursHand = document.querySelector('.hour-hand');
73+
const minutesHand = document.querySelector('.min-hand');
74+
const secondsHand = document.querySelector('.second-hand');
75+
76+
function setRotate(elem, time) {
77+
const deg = time / 60 * 360 + 90;
78+
elem.style.transform = `rotate(${deg}deg)`;
79+
}
80+
81+
function setTime() {
82+
const now = new Date();
83+
84+
const hours = now.getHours();
85+
setRotate(hoursHand, hours);
86+
87+
const minutes = now.getMinutes();
88+
setRotate(minutesHand, minutes);
89+
90+
const seconds = now.getSeconds();
91+
setRotate(secondsHand, seconds);
92+
}
93+
94+
setInterval(setTime, 1000);
6995

96+
setTime();
7097

7198
</script>
7299
</body>

0 commit comments

Comments
 (0)