Skip to content

Commit 0736edd

Browse files
committed
solved 01
1 parent 6597ebe commit 0736edd

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,35 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
transition: all .05s;
67+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 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+
77+
function setDate(){
78+
const now = new Date()
79+
const seconds = now.getSeconds()
80+
const min = now.getMinutes()
81+
const hour = now.getHours()
6982

83+
const secondsDegrees = ((seconds / 60) * 360) + 90
84+
const minDegrees = ((min / 60) * 360) + 90
85+
const hourDegrees = ((hour / 12) * 360) + 90
7086

87+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`
88+
minuteHand.style.transform = `rotate(${minDegrees}deg)`
89+
hourHand.style.transform = `rotate(${hourDegrees}deg)`
90+
}
91+
92+
setInterval(setDate, 1000)
7193
</script>
7294
</body>
7395
</html>

0 commit comments

Comments
 (0)