changeset 1341:a8bc1ee455ae

browser (slideshow): use standard click/dblclick instead of swiper equivalents: using swiper events cause troubles will managing event propagation (notably with media player)
author Goffi <goffi@goffi.org>
date Mon, 24 Aug 2020 22:49:24 +0200
parents d5f6793dc17c
children 1df0d1b28b83
files libervia/pages/_browser/slideshow.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/pages/_browser/slideshow.py	Mon Aug 24 22:47:51 2020 +0200
+++ b/libervia/pages/_browser/slideshow.py	Mon Aug 24 22:49:24 2020 +0200
@@ -84,9 +84,12 @@
         window.addEventListener("keydown", self.on_key_down, True)
         self.slideshow_elt.select_one(".click_to_close").bind("click", self.on_close)
         self.slideshow_elt.select_one(".click_to_comment").bind("click", self.on_comment)
+        # we don't use swiper.on for "click" and "dblclick" (or "doubleTap" in swiper
+        # terms) because it breaks event propagation management, which cause trouble with
+        # media player
+        self.slideshow_elt.bind("click", self.on_click)
+        self.slideshow_elt.bind("dblclick", self.on_dblclick)
         self.swiper.on("slideChange", self.on_slide_change)
-        self.swiper.on("click", self.on_click)
-        self.swiper.on("doubleTap", self.on_double_tap)
         self.on_slide_change(self.swiper)
         self.fullscreen(True)
 
@@ -156,14 +159,16 @@
             elt.style.display = '' if self.control_hidden else 'none'
         self.control_hidden = not self.control_hidden
 
-    def on_click(self, swiper, evt):
+    def on_click(self, evt):
+        evt.stopPropagation()
+        evt.preventDefault()
         # we use a timer so double tap can cancel the click
         # this avoid double tap side effect
         if self.click_timer is None:
             self.click_timer = timer.set_timeout(
                 lambda: self.toggle_hide_controls(evt), 300)
 
-    def on_double_tap(self, swiper, evt):
+    def on_dblclick(self, evt):
         evt.stopPropagation()
         evt.preventDefault()
         if self.click_timer is not None: