Skip to content

Commit 0b73a5f

Browse files
committed
completed project 2
1 parent e46e44a commit 0b73a5f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,42 @@
6363
background: black;
6464
position: absolute;
6565
top: 50%;
66+
transform-origin: 100%;
67+
transform: rotate(90deg);
68+
transition: all 0.2s;
69+
transition-timing-function: cubic-bezier(0.16, 2.29, 0.74, 0.75);
6670
}
6771

6872
</style>
6973

7074
<script>
7175

76+
const secondHand = document.querySelector('.second-hand');
77+
const minuteHand = document.querySelector('.min-hand');
78+
const hourHand = document.querySelector('.hour-hand');
79+
80+
function setDate () {
81+
const now = new Date();
82+
83+
const seconds = now.getSeconds();
84+
const secondsDegrees = ((seconds / 60) * 360) + 90;
85+
86+
const minutes = now.getMinutes();
87+
const minutesDegrees = ((minutes / 60) * 360) + ((seconds / 60) * 6) + 90;
88+
89+
const hour = now.getHours();
90+
const hourDegrees = ((hour / 12) * 360) + ((minutes / 60) * 30) + 90;
91+
92+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`
93+
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`
94+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
95+
96+
console.log(seconds)
97+
98+
99+
}
100+
101+
setInterval(setDate, 1000);
72102

73103
</script>
74104
</body>

0 commit comments

Comments
 (0)