Skip to content

Commit dd3058b

Browse files
committed
Completed exercise 02
1 parent 4e3128e commit dd3058b

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

02 - JS + CSS Clock/index.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,36 +61,36 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64-
transform-origin: 100%;
64+
transform-origin:right; /*same as transform-origin:100%. Use values over 100% to transfrom about a point off the object*/
6565
transform: rotate(90deg);
6666
transition: all 0.05s;
67-
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
67+
transition-timing-function: cubic-bezier(0, 2.7, 0.58, 1);
6868
}
69-
</style>
7069

71-
<script>
72-
const secondHand = document.querySelector('.second-hand');
73-
const minsHand = document.querySelector('.min-hand');
74-
const hourHand = document.querySelector('.hour-hand');
70+
</style>
7571

76-
function setDate() {
77-
const now = new Date();
72+
<script>
7873

79-
const seconds = now.getSeconds();
80-
const secondsDegrees = ((seconds / 60) * 360) + 90;
81-
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
74+
const secondHand = document.querySelector('.second-hand');
75+
const minuteHand = document.querySelector('.min-hand');
76+
const hourHand = document.querySelector('.hour-hand');
8277

83-
const mins = now.getMinutes();
84-
const minsDegrees = ((mins / 60) * 360) + 90;
85-
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
86-
87-
const hour = now.getMinutes();
88-
const hourDegrees = ((mins / 12) * 360) + 90;
89-
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
90-
}
78+
function setDate() {
79+
const now = new Date();
80+
const seconds = now.getSeconds();
81+
const minutes = now.getMinutes();
82+
const hours = now.getHours();
83+
const secondsDegrees = (seconds * 6) + 90 /*(seconds/60 * 360) = seconds * 6)*/
84+
const minutesDegrees = (minutes * 6) + 90
85+
const hoursDegrees = (hours * 30) + 90 /*360/12 = 30 */
86+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
87+
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`;
88+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
89+
}
9190

92-
setInterval(setDate, 1000);
91+
setInterval(setDate, 1000); /*built in function that runs a function at a given period
92+
document.querySelector(`.second-hand');*/
9393

94-
</script>
94+
</script>
9595
</body>
9696
</html>

0 commit comments

Comments
 (0)