-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.js
51 lines (47 loc) · 1.39 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
window.addEventListener("load", () => {
const sounds = document.querySelectorAll(".sound");
const pads = document.querySelectorAll(".pads div"); // this selects all the divs inside pads
const visual = document.querySelector(".visual");
const colors =
[
"#60d394",
"#d36060",
"#c060d3",
"#d3d160",
"#00B3FF",
"#e60808",
"#f5ec42",
"#010714",
"#e099a0",
"#33de00",
"#050505",
"#00F96D",
"#D612FF",
"#fff12e",
"#FF0000",
"#2954c2",
"#e099a0",
"#D612FF"
];
//Lets get going with the sound here
pads.forEach((pad, index) =>
{
pad.addEventListener("click", function()
{
sounds[index].currentTime = 0; //allows multiple clicks of the same sound
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);
});
};
});