changeset 1309:9344ca3b21a6

browser (slideshow): fixed scrolling issue with comment panel: all elements present in body before slideshow is added are hidden, and comments panel is now added to slideshow itself.
author Goffi <goffi@goffi.org>
date Sat, 01 Aug 2020 16:47:21 +0200
parents 7a4a92cf5b2b
children 9e356f8eb62c
files libervia/pages/_browser/slideshow.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/pages/_browser/slideshow.py	Thu Jul 16 09:08:50 2020 +0200
+++ b/libervia/pages/_browser/slideshow.py	Sat Aug 01 16:47:21 2020 +0200
@@ -11,6 +11,7 @@
         self.slideshow_elt = slideshow_tpl.get_elt()
         self.comments_count_elt = self.slideshow_elt.select_one('.comments__count')
         self.wrapper = self.slideshow_elt.select_one(".swiper-wrapper")
+        self.hidden_elts = {}
 
     @property
     def current_slide(self):
@@ -45,6 +46,10 @@
             self.swiper.slideTo(idx, 0)
 
     def attach(self):
+        # we hide other elts to avoid scrolling issues
+        for elt in document.body.children:
+            self.hidden_elts[elt] = elt.style.display
+            elt.style.display = "none"
         document.body <= self.slideshow_elt
         self.swiper = Swiper.new(
             ".swiper-container",
@@ -79,6 +84,10 @@
         self.swiper.update()
 
     def quit(self):
+        # we unhide
+        for elt, display in self.hidden_elts.items():
+            elt.style.display = display
+        self.hidden_elts.clear()
         self.slideshow_elt.remove()
         self.slideshow_elt = None
         self.swiper.destroy(True, True)
@@ -127,7 +136,7 @@
             "comments_node": item['comments_node'],
 
         })
-        document.body <= self.comments_panel_elt
+        self.slideshow_elt <= self.comments_panel_elt
         side_panel = self.comments_panel_elt.select_one('.comments_side_panel')
         window.setTimeout(lambda: side_panel.classList.add("open"))
         for close_elt in self.comments_panel_elt.select('.click_to_close'):