-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (31 loc) · 886 Bytes
/
script.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
window.addEventListener("load", () => {
const sounds = document.querySelectorAll(".sound");
const pads = document.querySelectorAll(".pads div");
const visual = document.querySelector(".visual");
const colors = [
"#60d394",
"#d36060",
"#c060d3",
"#d3d160",
"#6860d3",
"#60b2d3"
];
// Let's get the sounds
pads.forEach((pad, index) =>
pad.addEventListener("click", function() {
sounds[index].currentTime = 0;
sounds[index].play();
createBubbles(index);
})
);
// Create a function that makes Bubbles
const createBubbles = index => {
const bubble = document.createElement("div");
visual.appendChild(bubble);
bubble.style.backgroundColor = colors[index];
bubble.style.animation = "jump 1s ease";
bubble.addEventListener("animationend", function() {
visual.removeChild(this);
});
};
});