Skip to content

Commit 7706c17

Browse files
committed
Completes Lesson 2.
Adds JS and CSS Clock
1 parent 2c779d4 commit 7706c17

File tree

2 files changed

+21
-94
lines changed

2 files changed

+21
-94
lines changed

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

Lines changed: 0 additions & 73 deletions
This file was deleted.

02 - JS + CSS Clock/index-FINISHED.html renamed to 02 - JS + CSS Clock/index.html

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<style>
2020
html {
21-
background:#018DED url(http://unsplash.it/1500/1000?image=881&blur=50);
21+
background:#333 url(http://unsplash.it/1500/1000?image=1035);
2222
background-size:cover;
2323
font-family:'helvetica neue';
2424
text-align: center;
@@ -66,33 +66,33 @@
6666
transition: all 0.05s;
6767
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
6868
}
69-
</style>
69+
</style>
7070

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

76-
function setDate() {
77-
const now = new Date();
76+
function setDate() {
77+
const now = new Date();
7878

79-
const seconds = now.getSeconds();
80-
const secondsDegrees = ((seconds / 60) * 360) + 90;
81-
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
79+
const seconds = now.getSeconds();
80+
const secondsDegree = (seconds*360/60) + 90;
81+
secondHand.style.transform = `rotate(${secondsDegree}deg)`;
8282

83-
const mins = now.getMinutes();
84-
const minsDegrees = ((mins / 60) * 360) + 90;
85-
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
83+
const min = now.getMinutes();
84+
const minDegree = (min*360/60) + 90;
85+
minHand.style.transform = `rotate(${minDegree}deg)`;
8686

87-
const hour = now.getHours();
88-
const hourDegrees = ((hour / 12) * 360) + 90;
89-
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
90-
}
87+
const hour = now.getHours();
88+
const hourDegree = (min*360/12) + 90;
89+
hourHand.style.transform = `rotate(${hourDegree}deg)`;
90+
}
9191

92-
setInterval(setDate, 1000);
92+
setInterval(setDate, 1000);
9393

94-
setDate();
94+
setDate();
9595

96-
</script>
96+
</script>
9797
</body>
9898
</html>

0 commit comments

Comments
 (0)