File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class DrumKit {
12
12
this . bpm = 150 ;
13
13
this . isPlaying = null ;
14
14
this . selects = document . querySelectorAll ( "select" ) ;
15
+ this . muteBtn = document . querySelectorAll ( ".mute" ) ;
15
16
}
16
17
activePad ( ) {
17
18
this . classList . toggle ( "active" ) ;
@@ -81,6 +82,35 @@ class DrumKit {
81
82
break ;
82
83
}
83
84
}
85
+ mute ( e ) {
86
+ const muteIndex = e . target . getAttribute ( "data-track" ) ;
87
+ e . target . classList . toggle ( "active" ) ;
88
+ if ( e . target . classList . contains ( "active" ) ) {
89
+ switch ( muteIndex ) {
90
+ case "0" :
91
+ this . KickAudio . volume = 0 ;
92
+ break ;
93
+ case "1" :
94
+ this . snareAudio . volume = 0 ;
95
+ break ;
96
+ case "2" :
97
+ this . hihatAudio . volume = 0 ;
98
+ break ;
99
+ }
100
+ } else {
101
+ switch ( muteIndex ) {
102
+ case "0" :
103
+ this . KickAudio . volume = 1 ;
104
+ break ;
105
+ case "1" :
106
+ this . snareAudio . volume = 1 ;
107
+ break ;
108
+ case "2" :
109
+ this . hihatAudio . volume = 1 ;
110
+ break ;
111
+ }
112
+ }
113
+ }
84
114
}
85
115
const drumKit = new DrumKit ( ) ;
86
116
@@ -101,3 +131,8 @@ drumKit.selects.forEach((select) => {
101
131
drumKit . changeSound ( e ) ;
102
132
} ) ;
103
133
} ) ;
134
+ drumKit . muteBtn . forEach ( ( btn ) => {
135
+ btn . addEventListener ( "click" , ( e ) => {
136
+ drumKit . mute ( e ) ;
137
+ } ) ;
138
+ } ) ;
Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ select {
110
110
font-size : 1rem ;
111
111
}
112
112
113
+ .mute .active {
114
+ background : rgb (182 , 182 , 182 );
115
+ color : white;
116
+ }
117
+
113
118
@keyframes playTrack {
114
119
from {
115
120
transform : scale (1 );
You can’t perform that action at this time.
0 commit comments