Skip to content

Commit 118ca4a

Browse files
committed
applied hand logic & movement
1 parent 2f509e0 commit 118ca4a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,36 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin:100%;
65+
transform:rotate(90deg);
66+
transition: all 0.05s;
67+
transition-timing-function: cubic-bezier(0.02, 1.01, 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+
//seconds
79+
const seconds = now.getSeconds();
80+
const secondsDegrees = ((seconds/60) * 360)+90;
81+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
82+
console.log(seconds)
83+
//minutes
84+
const minutes = now.getMinutes();
85+
const minutesDegrees = ((minutes/60)*360)+90;
86+
minuteHand.style.transform =`rotate(${minutesDegrees}deg)`;
87+
//hours
88+
const hours = now.getHours();
89+
const hoursDegrees = ((hours/60)*360)+90;
90+
hourHand.style.transform =`rotate(${hoursDegrees}deg)`;
91+
}
6992

93+
setInterval(setDate, 1000);
7094

7195
</script>
7296
</body>

0 commit comments

Comments
 (0)