Skip to content

Commit cd53161

Browse files
author
Greg Pfaff
committed
adding comments
1 parent 9455d77 commit cd53161

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

01 - JavaScript Drum Kit/index-START.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,34 @@ <h1>#JavaScript30 Drum Example</h1>
6262

6363
<script>
6464

65+
// keydown listener
6566
window.addEventListener('keydown', drummer);
6667

6768
function removeTransition(e) {
69+
// if propertyName is not a transform end function
6870
if (e.propertyName !== 'transform') return;
69-
console.log(e.propertyName);
71+
// add remove class of playing on the elem that called it
7072
this.classList.remove('playing');
7173
}
7274

7375
function drummer(e) {
74-
console.log(e.keyCode);
7576

77+
// sets up constants
7678
const audio = document.querySelector(`audio[data-key="${e.keyCode}"`);
7779
const drum = document.querySelector(`div[data-key="${e.keyCode}"`);
7880

81+
// if not an audio tag end function
7982
if (!audio) return;
83+
// reset play time to 0
8084
audio.currentTime = 0;
85+
// play corresponding audio tag
8186
audio.play();
87+
// add playing class for css effect
8288
drum.classList.add('playing');
8389
}
8490

85-
//drum loop
86-
91+
//drum loop and transitionend key
92+
8793
const drums = document.querySelectorAll('.drum');
8894
drums.forEach(drum => drum.addEventListener('transitionend', removeTransition));
8995

0 commit comments

Comments
 (0)