Visitar URL original
Day 2 CSS + JS Clock · wesbos/JavaScript30@e98c2ac · GitHub
Skip to content

Commit e98c2ac

Browse files
committed
Day 2 CSS + JS Clock
1 parent 2a91d1f commit e98c2ac

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,36 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
transition: all 0.5s;
67+
transition-timing-function: cubic-bezier(0.07, 1.76, 1, 1);
6468
}
6569

6670
</style>
6771

6872
<script>
73+
const secondHand = document.querySelector('.second-hand');
74+
const minuteHand = document.querySelector('.min-hand');
75+
const hourHand = document.querySelector('.hour-hand');
76+
function setDate() {
77+
const now = new Date();
78+
const seconds = now.getSeconds();
79+
const secondsDegrees = ((seconds / 60) * 360 + 90);
80+
const minutes = now.getMinutes();
81+
const minutesDegrees = ((minutes / 60 ) * 360 + 90);
82+
const hours = now.getHours();
83+
const hoursDegrees = ((hours / 24) * 360 + 90);
84+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
85+
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`;
86+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
87+
console.log(seconds);
88+
}
89+
90+
setInterval(setDate, 1000);
91+
92+
93+
6994

7095

7196
</script>

0 commit comments

Comments
 (0)