# HG changeset patch # User Goffi # Date 1600375827 -7200 # Node ID 3c5054a22e7a0e3762f287cfd6a65315722b7c1a # Parent dbd573b0bc9cc71c4c6d862e51a50b1c4025f256 browser (slideshow): better handling of controls hiding: - use `slideshow_control` class instead of `click_to_hide` - check parents for the presence of this class (when a click on comments icon happen, it's the parent which has the `slideshow_control` class - stop propagation of events when closing comments tab, to avoid hiding controls accidentally diff -r dbd573b0bc9c -r 3c5054a22e7a libervia/pages/_browser/slideshow.py --- a/libervia/pages/_browser/slideshow.py Thu Sep 17 22:46:55 2020 +0200 +++ b/libervia/pages/_browser/slideshow.py Thu Sep 17 22:50:27 2020 +0200 @@ -97,6 +97,7 @@ 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 @@ -182,10 +183,15 @@ def toggle_hide_controls(self, evt): self.click_timer = None - if 'click_to_hide' in evt.target.classList: - # we don't want to hide controls when a control is clicked - return - for elt in self.slideshow_elt.select('.click_to_hide'): + # we don't want to hide controls when a control is clicked + # so we check all ancestors if we are not in a control + current = evt.target + while current and current != self.slideshow_elt: + print(f"current: {current}") + if 'slideshow_control' in current.classList: + return + current = current.parent + for elt in self.slideshow_elt.select('.slideshow_control'): elt.style.display = '' if self.control_hidden else 'none' self.control_hidden = not self.control_hidden @@ -216,6 +222,7 @@ self.quit() def on_comment_close(self, evt): + evt.stopPropagation() side_panel = self.comments_panel_elt.select_one('.comments_side_panel') side_panel.classList.remove('open') side_panel.bind("transitionend", lambda evt: self.comments_panel_elt.remove())