mouse wheel on volume slider
This commit is contained in:
parent
b8d4cf6fa1
commit
a07de062cd
@ -10,6 +10,7 @@
|
||||
var mute = document.querySelector('#player-mute')
|
||||
var vol = document.querySelector('#player-volbar')
|
||||
var volBar = document.querySelector('#player-volbar .seek-inner')
|
||||
var volElem = document.querySelector('.volume')
|
||||
|
||||
// Seconds into HH:MM:SS
|
||||
function toHHMMSS (numbr) {
|
||||
@ -173,11 +174,25 @@
|
||||
|
||||
mute.addEventListener('click', function (e) {
|
||||
audio.muted = !audio.muted
|
||||
updateVolume()
|
||||
}, false)
|
||||
|
||||
registerSeekBar(seek, 'currentTime', 'duration')
|
||||
registerSeekBar(vol, 'volume')
|
||||
|
||||
function wheelVolume (e) {
|
||||
var delta = e.wheelDelta || -e.detail
|
||||
if (delta < -1) delta = -1
|
||||
if (delta > 1) delta = 1
|
||||
|
||||
let av = audio.volume + (delta / 10)
|
||||
if (av > 1) av = 1
|
||||
if (av < 0) av = 0
|
||||
|
||||
audio.volume = av
|
||||
}
|
||||
|
||||
volElem.addEventListener('DOMMouseScroll', wheelVolume, false)
|
||||
volElem.addEventListener('mousewheel', wheelVolume, false)
|
||||
|
||||
updateVolume()
|
||||
})()
|
||||
|
Loading…
Reference in New Issue
Block a user