feat: add mouse wheel support for fullscreen volume control
Added event handler to allow adjusting the fullscreen volume using the mouse wheel. Scrolling up unmutes and increases volume, scrolling down decreases volume. Improves user experience for volume adjustments in fullscreen mode.
This commit is contained in:
parent
c7a4ba194d
commit
277d8e801b
1 changed files with 19 additions and 0 deletions
19
js/ui.js
19
js/ui.js
|
|
@ -1344,6 +1344,25 @@ export class UIRenderer {
|
|||
updateFsVolumeUI();
|
||||
};
|
||||
|
||||
const handleFsVolumeWheel = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const delta = e.deltaY > 0 ? -0.05 : 0.05;
|
||||
const currentVolume = this.player.userVolume;
|
||||
const newVolume = Math.max(0, Math.min(1, currentVolume + delta));
|
||||
|
||||
if (delta > 0 && this.player.muted) {
|
||||
this.player.setMute(false);
|
||||
}
|
||||
|
||||
this.player.setVolume(newVolume);
|
||||
updateFsVolumeUI();
|
||||
};
|
||||
|
||||
[fsVolumeBar, fsVolumeBtn].forEach((el) =>
|
||||
el.addEventListener('wheel', handleFsVolumeWheel, { passive: false })
|
||||
);
|
||||
|
||||
const setFsVolume = (e) => {
|
||||
const rect = fsVolumeBar.getBoundingClientRect();
|
||||
const position = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
||||
|
|
|
|||
Loading…
Reference in a new issue