Skip to content

Commit 1a76a95

Browse files
committed
Completion of lecture wesbos#2
1 parent fef238e commit 1a76a95

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,38 @@
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);
68+
6469
}
6570

6671
</style>
6772

6873
<script>
74+
const secondHand = document.querySelector('.second-hand');
75+
const minuteHand = document.querySelector('.min-hand');
76+
const hourHand = document.querySelector('.hour-hand');
77+
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) + 90;
88+
minuteHand.style.transform = `rotate(${minsDegrees}deg)`;
89+
90+
const hours = now.getHours();
91+
const hoursDegrees = ((hours / 12) * 360) + 90;
92+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
93+
}
6994

95+
setInterval(setDate, 1000);
7096

7197
</script>
7298
</body>

0 commit comments

Comments
 (0)