Skip to content

Commit 96dd664

Browse files
committed
lesson
1 parent c1a6a9d commit 96dd664

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,40 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transition-duration: 0.5s;
65+
transition-property: transform;
66+
transition-rotate: rotate(0deg);
67+
transition-timing-function: linear;
68+
transform-origin: 100%;
6469
}
6570

6671
</style>
6772

6873
<script>
74+
const hourHand = document.querySelector('.hour-hand');
75+
const minHand = document.querySelector('.min-hand');
76+
const secondHand = document.querySelector('.second-hand');
6977

78+
function setTime(){
79+
const date = new Date();
80+
let seconds = date.getSeconds();
81+
let minutes = date.getMinutes();
82+
let hours = date.getHours();
83+
84+
if (seconds / 60 == 1){
85+
secondHand.style.transition = 'none';
86+
}else{
87+
secondHand.style = '';
88+
}
7089

90+
91+
hourHand.style.transform = `rotate(${Number(hours*360/12 + 90)}deg)`;
92+
minHand.style.transform = `rotate(${Number(minutes*360/60 + 90)}deg)`;
93+
secondHand.style.transform = `rotate(${Number(seconds*360/60 + 90)}deg)`;
94+
console.log(hours,':',minutes,':',seconds);
95+
}
96+
97+
setInterval(setTime, 1000);
7198
</script>
7299
</body>
73100
</html>

0 commit comments

Comments
 (0)