Skip to content

Commit 15bcd49

Browse files
committed
completed wesbos#2
1 parent 802a82a commit 15bcd49

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,64 @@
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.8, 0.82, 1);
6569
}
6670

6771
</style>
6872

6973
<script>
7074

75+
// const secondHand = document.querySelector('.second-hand');
76+
// const minHand = document.querySelector('.min-hand');
77+
// const hourHand = document.querySelector('.hour-hand');
78+
//
79+
// let secondHandAngle = 90;
80+
// let minHandAngle = 90;
81+
// let hourHandAngle = 90;
82+
//
83+
// function handChanger(unit) {
84+
// if (unit === 's') {
85+
// secondHand.style.transform = 'rotate('+secondHandAngle+'deg)';
86+
// secondHandAngle += 6;
87+
// } else if (unit === 'm') {
88+
// minHand.style.transform = 'rotate('+minHandAngle+'deg)';
89+
// minHandAngle += 6;
90+
// } else if (unit === 'h') {
91+
// hourHand.style.transform = 'rotate('+hourHandAngle+'deg)';
92+
// hourHandAngle += 6;
93+
// }
94+
// }
95+
//
96+
// setInterval(function() { handChanger('s') }, 1000);
97+
// setInterval(function() { handChanger('m') }, 60000);
98+
// setInterval(function() { handChanger('h') }, 3600000);
99+
100+
const secondHand = document.querySelector('.second-hand');
101+
const minuteHand = document.querySelector('.min-hand');
102+
const hourHand = document.querySelector('.hour-hand');
103+
104+
function setDate() {
105+
const now = new Date();
106+
const seconds = now.getSeconds();
107+
const secondsDegree = (seconds / 60) * 360 + 90;
108+
secondHand.style.transform = `rotate(${secondsDegree}deg)`;
109+
console.log(seconds);
110+
111+
const minutes = now.getMinutes();
112+
const minutesDegree = (minutes / 60) * 360 + 90;
113+
minuteHand.style.transform = `rotate(${minutesDegree}deg)`;
114+
console.log(minutes);
115+
116+
const hours = now.getHours();
117+
const hoursDegree = (hours / 12) * 360 + 90;
118+
hourHand.style.transform = `rotate(${hoursDegree}deg)`;
119+
console.log(hours);
120+
}
121+
122+
setInterval(setDate,1000);
71123

72124
</script>
73125
</body>

0 commit comments

Comments
 (0)