mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use input instead of change for volume control
This commit is contained in:
parent
a664449681
commit
aad5b23e2b
1 changed files with 10 additions and 3 deletions
|
@ -160,7 +160,7 @@
|
|||
this.controlEvents = [
|
||||
{ el: this.elements.playPauseButton, type: "click"},
|
||||
{ el: this.elements.volumeSwitch, type: "click" },
|
||||
{ el: this.elements.volumeLevel, type: "change" },
|
||||
{ el: this.elements.volumeLevel, type: "input" },
|
||||
];
|
||||
this.controlEvents.forEach(({ el, type }) => {
|
||||
el.addEventListener(type, this);
|
||||
|
@ -269,10 +269,10 @@
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case "change":
|
||||
case "input":
|
||||
switch (event.currentTarget) {
|
||||
case this.elements.volumeLevel:
|
||||
this.render();
|
||||
this.changeVolume();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -322,6 +322,13 @@
|
|||
muteUnmute() {
|
||||
this.media.muted = !this.media.muted;
|
||||
}
|
||||
|
||||
changeVolume() {
|
||||
const volume = parseInt(this.elements.volumeLevel.value);
|
||||
if (!isNaN(volume)) {
|
||||
this.media.volume = volume / 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new MediaControls();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue