Skip to content

Commit c102671

Browse files
committed
day 2 first attempt
1 parent fd62ffa commit c102671

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

01 - JavaScript Drum Kit/index-START.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,14 @@
5959

6060
<script>
6161
document.body.onkeydown = function(e){
62-
var key = document.querySelector(`.key[data-key="${e.which}"]`)
6362
var audio = document.querySelector(`audio[data-key="${e.which}"]`)
63+
if (!audio) {
64+
return
65+
}
66+
audio.currentTime = 0
6467
audio.play()
68+
69+
var key = document.querySelector(`.key[data-key="${e.which}"]`)
6570
key.classList.add('playing')
6671
setTimeout(() => key.classList.remove('playing'), 60)
6772
}

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,40 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform: rotate(90deg);
65+
transform-origin: 100%;
66+
transition: all 0.06s;
67+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1)
6468
}
6569

6670
</style>
6771

6872
<script>
73+
var hourHand = document.querySelector('.hour-hand')
74+
var minHand = document.querySelector('.min-hand')
75+
var secondHand = document.querySelector('.second-hand')
6976

77+
setInterval(() => {
78+
var now = new Date()
79+
var hour = now.getHours()
80+
var min = now.getMinutes()
81+
var second = now.getSeconds()
82+
83+
var hourAngle = ((60*hour)/2 + 90)
84+
var minAngle = 6 * min + 90
85+
var secondAngle = 6 * second + 90
86+
87+
console.log(hourAngle)
88+
console.log(minAngle)
89+
console.log(secondAngle)
90+
91+
hourHand.style.transform = `rotate(${hourAngle}deg)`
92+
hourHand.style.background = 'red'
93+
minHand.style.transform = `rotate(${minAngle}deg)`
94+
minHand.style.background = 'green'
95+
secondHand.style.transform = `rotate(${secondAngle}deg)`
96+
console.log(now)
97+
}, 1000)
7098

7199
</script>
72100
</body>

0 commit comments

Comments
 (0)