X Tutup
Skip to content

Commit ef229c2

Browse files
committed
finished Day 2
1 parent e1c5883 commit ef229c2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,37 @@
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(1,0,.6,1.75);
6569
}
6670

6771
</style>
6872

6973
<script>
74+
const hourHand = document.querySelector('.hour-hand');
75+
const secondHand = document.querySelector('.second-hand');
76+
const minuteHand = document.querySelector('.min-hand');
7077

78+
function setDate() {
79+
const now = new Date();
80+
const hours = now.getHours();
81+
const minutes = now.getMinutes();
82+
let seconds = now.getSeconds();
7183

84+
const hoursDegrees = ((hours / 24) * 360);
85+
const minutesDegrees = ((minutes / 60) * 360) + 90;
86+
const secondsDegrees = ((seconds / 60) * 360) + 90;
87+
88+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
89+
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`;
90+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
91+
92+
console.log(`${hours}:${minutes}::${seconds}`);
93+
}
94+
95+
setInterval(setDate, 1000);
7296
</script>
7397
</body>
7498
</html>

0 commit comments

Comments
 (0)
X Tutup