Skip to content

Commit d5b68d5

Browse files
committed
finished wesbos#2
1 parent 27bbf93 commit d5b68d5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,39 @@
6262
background: black;
6363
position: absolute;
6464
top: 50%;
65+
transform-origin: 100%;
66+
transform: rotate(90deg);
67+
transition: all 0.05s;
68+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
69+
6570
}
6671

6772
</style>
6873

6974
<script>
75+
const secondHand = document.querySelector('.second-hand');
76+
const minsHand = document.querySelector('.min-hand');
77+
const hourHand = document.querySelector('.hour-hand');
78+
79+
function setDate() {
80+
const now = new Date();
81+
82+
const seconds = now.getSeconds();
83+
const secondsDegrees = ((seconds / 60) * 360) + 90;
84+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
85+
86+
const mins = now.getMinutes();
87+
const minsDegrees = ((mins / 60) * 360) + ((seconds/60)*6) + 90;
88+
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
89+
90+
const hour = now.getHours();
91+
const hourDegrees = ((hour / 12) * 360) + ((mins/60)*30) + 90;
92+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
93+
}
94+
95+
setInterval(setDate, 1000);
96+
97+
setDate();
7098

7199

72100
</script>

03 - CSS Variables/index-START.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
1919
</div>
2020

2121
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">
22-
22+
2323
<style>
2424

2525
/*

0 commit comments

Comments
 (0)