-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (51 loc) · 1.36 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
56
const drums = new Howl({
"src": [
"./sounds/drums.webm"
],
"sprite": {
"BD-24b": [
0,
2266.689342403628
],
"CCYM.3": [
4000,
6000
],
"HTGreen_0002": [
11000,
5904.08163265306
],
"LTSuperSoft_0002": [
18000,
5965.034013605443
],
"RCStick.3": [
25000,
5000
],
"RCSuperSoft_0002": [
31000,
10798.61678004535
]
}
});
const drumSet = document.querySelector('.drums');
console.log(drumSet)
function playDrums(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;
document.documentElement.style.setProperty('--vh', `${vh}px`)
}
// // this may not be necessary
// setViewportHeight();
// window.addEventListener('resize', () => {
// setTimeout(setViewportHeight, 100);
// });
drumSet.addEventListener('click', playDrums);
drumSet.addEventListener('touchstart', playDrums);