Visitar URL original
Complete · wesbos/JavaScript30@c270487 · GitHub
Skip to content

Commit c270487

Browse files
committed
Complete
1 parent 4405dfc commit c270487

3 files changed

Lines changed: 40 additions & 101 deletions

File tree

‎02 - JS + CSS Clock/clockCtrl.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const secondHand = document.querySelector('.second-hand');
2+
3+
const minHand = document.querySelector('.min-hand');
4+
5+
const hourHand = document.querySelector('.hour-hand');
6+
7+
function setDate() {
8+
const now = new Date();
9+
10+
// Seconds hand controller
11+
const seconds = now.getSeconds();
12+
const secondsDegrees = ((seconds / 60) * 360) + 90;
13+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
14+
// console.log(seconds);
15+
16+
// minute hand controller
17+
const minutes = now.getMinutes();
18+
const minDegrees = ((minutes / 60) * 360) + 90;
19+
minHand.style.transform = `rotate(${minDegrees}deg)`;
20+
// console.log(minutes);
21+
22+
//Hour hand controller
23+
const hour = now.getHours();
24+
const hourDegrees = ((hour / 24) * 360) + 90;
25+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
26+
// console.log(hour);
27+
};
28+
29+
setInterval(setDate, 1000);

‎02 - JS + CSS Clock/index-FINISHED.html‎

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

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,21 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
/*transition: all 0.05s;*/
6467
}
6568

66-
</style>
69+
.second-hand {
70+
height: 4px;
71+
}
6772

68-
<script>
73+
.hour-hand {
74+
height: 4px;
75+
}
6976

77+
</style>
7078

71-
</script>
79+
<script src="clockCtrl.js"></script>
7280
</body>
7381
</html>

0 commit comments

Comments
 (0)