Skip to content

Commit 4af3f57

Browse files
committed
first wes bos completed
1 parent 650e837 commit 4af3f57

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

01 - JavaScript Drum Kit/index-START.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,21 @@
5858
<audio data-key="76" src="sounds/tink.wav"></audio>
5959

6060
<script>
61-
61+
function removeTransition(e){
62+
if(e.propertyName !== 'transform') return
63+
this.classList.remove('playing')
64+
}
65+
function playSound (e){
66+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`)
67+
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`)
68+
if(!audio) return
69+
audio.currentTime = 0
70+
audio.play()
71+
key.classList.add('playing')
72+
}
73+
window.addEventListener('keydown',playSound)
74+
const keys = document.querySelectorAll('.key')
75+
keys.forEach(key => key.addEventListener('transitionend',removeTransition))
6276
</script>
6377

6478

01 - JavaScript Drum Kit/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ body,html {
3232
}
3333

3434
.playing {
35-
transform: scale(1.1);
35+
transform: scale(1.6);
3636
border-color: #ffc600;
3737
box-shadow: 0 0 1rem #ffc600;
3838
}

0 commit comments

Comments
 (0)