Skip to content

Commit e96db65

Browse files
author
Miguel Bautista
committed
02 done
1 parent 034d580 commit e96db65

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,30 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%; /* moves origin of skew/ animation along x-axis*/
65+
transform: rotate(90deg);
66+
transition: all 0.5s;
67+
transition-timing-function: cubic-bezier(0.1,2.7,0.58,1);
6468
}
6569

66-
</style>
70+
.hour-hand{
71+
height: 10px;
72+
width: 40%;
73+
transform-origin: 110%;
74+
}
6775

68-
<script>
76+
.minute-hand{
77+
height: 5px;
78+
}
6979

80+
.second-hand{
81+
height: 2px;
82+
background: white;
83+
}
84+
85+
86+
</style>
7087

71-
</script>
88+
<script type="text/javascript" src="js/entry.js"></script>
7289
</body>
7390
</html>

02 - JS + CSS Clock/js/entry.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const secondHand = document.querySelector('.second-hand');
2+
const hourHand = document.querySelector('.hour-hand');
3+
const minuteHand = document.querySelector('.min-hand');
4+
5+
6+
function setDate(){
7+
const now = new Date(); // built into JS. Represents a single moment in time.
8+
const seconds = now.getSeconds();
9+
const minutes = now.getMinutes();
10+
const hours = now.getHours();
11+
const secondsDegrees = ((seconds / 60) * 360) + 90;
12+
const minutesDegrees = ((minutes / 60) * 360) + 90;
13+
const hoursDegrees = ((hours / 12) * 360) + 90;
14+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
15+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
16+
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`;
17+
}
18+
19+
setInterval(setDate, 1000);

0 commit comments

Comments
 (0)