-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
34 lines (31 loc) · 1 KB
/
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",
"#6b60d3",
"#60aed3",
];
//lets go with sounds
pads.forEach((pad, index) => {
pad.addEventListener("click", function() {
sounds[index].currentTime = 0;
sounds[index].play();
createBubbles(index);
});
});
// Create a function to create bubbles
const createBubbles = (index) => {
const bubble = document.createElement("div");
visual.appendChild(bubble);
bubble.style.backgroundColor = colors[index];
bubble.style.animation = 'jump 1s in ease';
bubble.addEventListener("animationend", function() {
visual.removeChild(this);
})
}
});