mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix clicks on bar being handled by container
This commit is contained in:
parent
fcc8795078
commit
79062e8a8c
@ -100,6 +100,7 @@ class ReadAudioEbook:
|
||||
]:
|
||||
bar_container.appendChild(x)
|
||||
|
||||
bar_container.addEventListener("click", self.on_bar_clicked, {"passive": False})
|
||||
self.container.appendChild(E.audio(data_component='audio', style="display:none"))
|
||||
ap = self.container.lastChild
|
||||
|
||||
@ -126,10 +127,11 @@ class ReadAudioEbook:
|
||||
ap = self.audio_player
|
||||
if ap.duration:
|
||||
rect = self.progress_bar.getBoundingClientRect()
|
||||
clickX = event.clientX - rect.left
|
||||
x = event.clientX - rect.left
|
||||
total_width = rect.width
|
||||
skip_time = (clickX / total_width) * ap.duration
|
||||
ap.currentTime = skip_time
|
||||
if total_width:
|
||||
skip_time = (x / total_width) * ap.duration
|
||||
ap.currentTime = skip_time
|
||||
)
|
||||
|
||||
@property
|
||||
@ -293,6 +295,10 @@ class ReadAudioEbook:
|
||||
elif self.state is PAUSED:
|
||||
self.play()
|
||||
|
||||
def on_bar_clicked(self, ev):
|
||||
# prevent the container click handler from handling this
|
||||
ev.stopPropagation(), ev.preventDefault()
|
||||
|
||||
def on_container_clicked(self, ev):
|
||||
if ev.button is not 0:
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user