Visitar URL original
Merge pull request #2 from cydseelen/js-clock · wesbos/JavaScript30@7388f78 · GitHub
Skip to content

Commit 7388f78

Browse files
authored
Merge pull request #2 from cydseelen/js-clock
Completed 2nd Challenge CSS Clock. Clock is working.
2 parents 7bf9349 + e89e32d commit 7388f78

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,36 @@
6262
background: black;
6363
position: absolute;
6464
top: 50%;
65+
transform-origin: 100%;
66+
transform: rotate(90deg);
67+
transition: all 0.05s;
68+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
6569
}
6670

6771
</style>
6872

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

78+
function setDate() {
79+
const now = new Date();
80+
81+
const seconds = now.getSeconds();
82+
const secondsDegrees = ((seconds / 60) * 360) + 90;
83+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
84+
85+
const mins = now.getMinutes();
86+
const minsDegrees = ((mins / 60) * 360) + 90;
87+
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
88+
89+
const hour = now.getMinutes();
90+
const hourDegrees = ((mins / 12) * 360) + 90;
91+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
92+
}
93+
94+
setInterval(setDate, 1000);
7195

7296
</script>
7397
</body>

0 commit comments

Comments
 (0)