-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (30 loc) · 840 Bytes
/
index.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
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",
"#606bd3",
"#60c2d3"
];
pads.forEach((pad, index) => {
pad.addEventListener("click", function() {
sounds[index].currentTime = 0;
sounds[index].play();
createBubble(index);
});
});
const createBubble = index => {
//Create bubbles
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);
});
};
});