Visitar URL original
clock · wesbos/JavaScript30@751b641 · GitHub
Skip to content

Commit 751b641

Browse files
author
Kara Schaefer
committed
clock
1 parent 59826fa commit 751b641

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎01 - JavaScript Drum Kit/style.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
html {
1+
/*html {*/
22
font-size: 10px;
33
background:url(http://i.imgur.com/b9r5sEL.jpg) bottom center;
44
background-size: cover;

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,48 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
transition: all 0.05s;
67+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
68+
}
69+
70+
.second-hand {
71+
background:yellow;
72+
}
73+
74+
.min-hand {
75+
background:blue;
76+
}
77+
78+
.hour-hand {
79+
6480
}
6581

6682
</style>
6783

6884
<script>
85+
const secondHand = document.querySelector('.second-hand');
86+
const minHand = document.querySelector('.min-hand');
87+
const hourHand = document.querySelector('.hour-hand')
88+
function setDate(){
89+
const now = new Date();
90+
const seconds = now.getSeconds();
91+
const secondsDegrees = ((seconds / 60) * 360) + 90;
92+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
6993

94+
const minutes = now.getMinutes();
95+
const minutesDegrees = ((minutes / 60) * 360) + 90;
96+
minHand.style.transform = `rotate(${minutesDegrees}deg)`;
97+
98+
const hours = (now.getMinutes() / 60);
99+
console.log(hours);
100+
const hoursDegrees = ((hours / 12) * 360) + 180;
101+
// console.log(hoursDegrees);
102+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
103+
}
70104

105+
setInterval(setDate, 1000);
71106
</script>
72107
</body>
73108
</html>

0 commit comments

Comments
 (0)