Visitar URL original
complete · wesbos/JavaScript30@5774936 · GitHub
Skip to content

Commit 5774936

Browse files
committed
complete
1 parent 5225ba9 commit 5774936

3 files changed

Lines changed: 27 additions & 191 deletions

File tree

‎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: 0 additions & 73 deletions
This file was deleted.

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

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,40 @@
6464
transform-origin: 100%;
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.41, 1.99, 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+
.second-hand {
71+
height: 4px;
72+
}
73+
74+
.hour-hand {
75+
height: 8px;
76+
}
77+
</style>
7578

76-
function setDate() {
77-
const now = new Date();
79+
<script>
80+
const secondHand = document.querySelector('.second-hand');
81+
const minuteHand = document.querySelector('.min-hand');
82+
const hourHand = document.querySelector('.hour-hand');
7883

79-
const seconds = now.getSeconds();
80-
const secondsDegrees = ((seconds / 60) * 360) + 90;
81-
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
84+
function setDate() {
85+
const now = new Date();
8286

83-
const mins = now.getMinutes();
84-
const minsDegrees = ((mins / 60) * 360) + 90;
85-
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
87+
const seconds = now.getSeconds();
88+
const secondsDegrees = ((seconds / 60) * 360) + 90;
89+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
8690

87-
const hour = now.getMinutes();
88-
const hourDegrees = ((mins / 12) * 360) + 90;
89-
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
90-
}
91+
const minutes = now.getMinutes();
92+
const minutesDegrees = ((minutes / 60) * 360) + 90;
93+
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`;
9194

92-
setInterval(setDate, 1000);
95+
const hours = now.getHours();
96+
const hoursDegrees = (((hours + (minutes / 60)) / 12) * 360) + 90;
97+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
98+
}
9399

94-
</script>
100+
setInterval(setDate, 1000);
101+
</script>
95102
</body>
96103
</html>

0 commit comments

Comments
 (0)