-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
28 lines (25 loc) · 925 Bytes
/
main.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
window.addEventListener('load', () => {
const sound = document.querySelectorAll('.sound');
const pads = document.querySelectorAll('.pads div');
const bubbles = document.querySelector('.visual');
const color = ['ffbe0b', 'fb5607', 'ff006e', '8338ec', '3a86ff', '5e6472'];
pads.forEach((pad, index) => {
pad.addEventListener('click', () => {
sound[index].currentTime = 0;
sound[index].play();
createBubble(index);
});
});
let createBubble = function (index) {
const bubble = document.createElement('div');
bubbles.appendChild(bubble);
bubble.style.background = `#${color[index]}`;
bubble.style.animation = 'jump 1s ease';
bubble.addEventListener('animationend', () => {
bubbles.removeChild(bubble);
});
};
});
if (window.Promise) {
console.log(window.Promise);
}