Skip to content

Commit 0c52c23

Browse files
committed
challenge wesbos#2 finished
1 parent 4d0b9b1 commit 0c52c23

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>JS + CSS Clock</title>
6-
<link rel="icon" href="https://fav.farm/🔥" />
6+
<link rel="icon" href="https://fav.farm/" />
77
</head>
88
<body>
99

@@ -63,13 +63,39 @@
6363
background: black;
6464
position: absolute;
6565
top: 50%;
66+
transform-origin: 100%;
67+
transform: rotate(90deg);
68+
transition: all 0.05s;
69+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
6670
}
71+
</style>
6772

68-
</style>
6973

70-
<script>
74+
<script>
75+
const secondHand = document.querySelector('.second-hand');
76+
const minsHand = document.querySelector('.min-hand');
77+
const hourHand = document.querySelector('.hour-hand');
7178

79+
function setDate() {
80+
const now = new Date();
7281

73-
</script>
82+
const seconds = now.getSeconds();
83+
const secondsDegrees = ((seconds / 60) * 360) + 90;
84+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
85+
86+
const mins = now.getMinutes();
87+
const minsDegrees = ((mins / 60) * 360) + ((seconds/60)*6) + 90;
88+
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
89+
90+
const hour = now.getHours();
91+
const hourDegrees = ((hour / 12) * 360) + ((mins/60)*30) + 90;
92+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
93+
}
94+
95+
setInterval(setDate, 1000);
96+
97+
setDate();
98+
99+
</script>
74100
</body>
75101
</html>

0 commit comments

Comments
 (0)