Skip to content

Commit ef4a193

Browse files
authored
Merge pull request #2 from hypatiah/day2
CSS and JS clock
2 parents d58410e + 8cd9f4e commit ef4a193

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,41 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
/*puts pivot point on very right hand side*/
65+
/*transform-origin: 100%;*/
66+
/*sets default 12 o'clock position*/
67+
/*transform: rotate(90deg);*/
68+
/*transition: all 0.5s;*/
69+
transform-origin: 100%;
70+
transform: rotate(90deg);
71+
transition: all 0.05s;
72+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
6473
}
6574

6675
</style>
6776

6877
<script>
78+
const secondHand = document.querySelector('.second-hand');
79+
const hourHand = document.querySelector('.hour-hand');
80+
const minuteHand = document.querySelector('.min-hand');
6981

82+
function setDate() {
83+
const now = new Date();
84+
const seconds = now.getSeconds();
85+
const secondsDegrees = ((seconds / 60) * 360) + 90;
86+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
7087

88+
const mins = now.getMinutes();
89+
const minsDegrees = ((mins / 60) * 360) + 90;
90+
minuteHand.style.transform = `rotate(${minsDegrees}deg)`
91+
92+
const hour = now.getHours();
93+
const hourDegrees = ((hour / 12) * 360) + 90;
94+
hourHand.style.transform = `rotate(${hourDegrees}deg)`
95+
console.log(seconds);
96+
}
97+
98+
setInterval(setDate, 1000);
7199
</script>
72100
</body>
73101
</html>

0 commit comments

Comments
 (0)