-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
41 lines (37 loc) · 1.09 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const music = document.querySelectorAll(".music");
const pads = document.querySelectorAll(".pads div");
const visual = document.querySelector(".motion");
const colors = [
'#f1a762',
'#ff8080',
'#a7e7c0',
'#a7a6f5',
'#f3f598',
'#f788f7',
]
console.log(music)
for(let i = 0; i < pads.length; i++){
console.log(music[i]);
pads[i].addEventListener("click", function() {
music[i].currentTime = 0;
music[i].play();
createBubble(i);
});
};
// pads.forEach((pad, index) => {
// pad.addEventListener("click", function() {
// music[index].currentTime = 0;
// music[index].play();
// // createBubble(index);
// });
// });
function createBubble(i){
//Create bubbles
const bubble = document.createElement("div");
visual.appendChild(bubble);
bubble.style.backgroundColor = colors[i];
bubble.style.animation = `jump 1s ease`;
bubble.addEventListener("animationend", function() {
visual.removeChild(this);
});
};