-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
55 lines (51 loc) · 1.16 KB
/
app.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
51
52
53
54
55
const drums= new Howl({
"src": [
"./drums/drums.webm",
"./drums/drums.mp3"
],
"sprite": {
"clap": [
0,
734.2630385487529
],
"closed-hithat": [
2000,
552.7891156462586
],
"crash": [
4000,
10185.260770975057
],
"kick": [
16000,
568.91156462585
],
"open-hithat": [
18000,
4946.0770975056685
],
"snare": [
24000,
1248.2539682539696
]
}
});
const drumkit = document.querySelector(".bateria");
function playDrum(event) {
if (event.target.classList.contains("pad")) {
event.preventDefault();
let soundToPlay = event.target.dataset.sound;
drums.play(soundToPlay);
}
}
function setViewportHeight() {
let vh = window.innerHeight * 0.01;
console.log(vh);
document.documentElement.style.setProperty("--vh", `${vh}px`);
}
setViewportHeight();
window.addEventListener("resize", () => {
setTimeout(setViewportHeight, 100);
});
drumkit.addEventListener("click", playDrum);
drumkit.addEventListener("touchstart", playDrum);