Mercurial > libervia-web
comparison libervia/pages/_browser/slideshow.py @ 1327:e35de70f5295
browser: updated swiper and use a limit on version
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 14 Aug 2020 09:31:32 +0200 |
parents | 0cbf86b1dcca |
children | 5ff6e187084f |
comparison
equal
deleted
inserted
replaced
1326:089742e065e3 | 1327:e35de70f5295 |
---|---|
82 self.slideshow_elt.select_one(".click_to_close").bind("click", self.on_close) | 82 self.slideshow_elt.select_one(".click_to_close").bind("click", self.on_close) |
83 self.slideshow_elt.select_one(".click_to_comment").bind("click", self.on_comment) | 83 self.slideshow_elt.select_one(".click_to_comment").bind("click", self.on_comment) |
84 self.swiper.on("slideChange", self.on_slide_change) | 84 self.swiper.on("slideChange", self.on_slide_change) |
85 self.swiper.on("click", self.on_click) | 85 self.swiper.on("click", self.on_click) |
86 self.swiper.on("doubleTap", self.on_double_tap) | 86 self.swiper.on("doubleTap", self.on_double_tap) |
87 self.on_slide_change() | 87 self.on_slide_change(self.swiper) |
88 self.fullscreen(True) | 88 self.fullscreen(True) |
89 | 89 |
90 def add_slide(self, elt, item_data=None): | 90 def add_slide(self, elt, item_data=None): |
91 slide_elt = html.DIV(Class="swiper-slide") | 91 slide_elt = html.DIV(Class="swiper-slide") |
92 zoom_cont_elt = html.DIV(Class="swiper-zoom-container") | 92 zoom_cont_elt = html.DIV(Class="swiper-zoom-container") |
135 self.quit() | 135 self.quit() |
136 else: | 136 else: |
137 return | 137 return |
138 evt.preventDefault() | 138 evt.preventDefault() |
139 | 139 |
140 def on_slide_change(self): | 140 def on_slide_change(self, swiper): |
141 item = self.current_item | 141 item = self.current_item |
142 if item is None: | 142 if item is None: |
143 return | 143 return |
144 comments_count = item.get('comments_count') | 144 comments_count = item.get('comments_count') |
145 self.comments_count_elt.text = comments_count or '' | 145 self.comments_count_elt.text = comments_count or '' |
151 return | 151 return |
152 for elt in self.slideshow_elt.select('.click_to_hide'): | 152 for elt in self.slideshow_elt.select('.click_to_hide'): |
153 elt.style.display = '' if self.control_hidden else 'none' | 153 elt.style.display = '' if self.control_hidden else 'none' |
154 self.control_hidden = not self.control_hidden | 154 self.control_hidden = not self.control_hidden |
155 | 155 |
156 def on_click(self, evt): | 156 def on_click(self, swiper, evt): |
157 # we use a timer so double tap can cancel the click | 157 # we use a timer so double tap can cancel the click |
158 # this avoid double tap side effect | 158 # this avoid double tap side effect |
159 if self.click_timer is None: | 159 if self.click_timer is None: |
160 self.click_timer = timer.set_timeout( | 160 self.click_timer = timer.set_timeout( |
161 lambda: self.toggle_hide_controls(evt), 300) | 161 lambda: self.toggle_hide_controls(evt), 300) |
162 | 162 |
163 def on_double_tap(self, evt): | 163 def on_double_tap(self, swiper, evt): |
164 evt.stopPropagation() | 164 evt.stopPropagation() |
165 evt.preventDefault() | 165 evt.preventDefault() |
166 if self.click_timer is not None: | 166 if self.click_timer is not None: |
167 timer.clear_timeout(self.click_timer) | 167 timer.clear_timeout(self.click_timer) |
168 self.click_timer = None | 168 self.click_timer = None |