Mercurial > libervia-web
comparison libervia/pages/_browser/slideshow.py @ 1312:39a87d9099c4
browser (slideshow): slides can now be zoomed:
zoom is activated either by double clicking/taping or by pinching on touch devices
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 Aug 2020 16:47:24 +0200 |
parents | 9948598e7ec0 |
children | 0cbf86b1dcca |
comparison
equal
deleted
inserted
replaced
1311:9948598e7ec0 | 1312:39a87d9099c4 |
---|---|
70 "keyboard": { | 70 "keyboard": { |
71 "enabled": True, | 71 "enabled": True, |
72 "onlyInViewport": False, | 72 "onlyInViewport": False, |
73 }, | 73 }, |
74 "mousewheel": True, | 74 "mousewheel": True, |
75 "zoom": { | |
76 "maxRatio": 15, | |
77 "toggle": False, | |
78 }, | |
75 } | 79 } |
76 ) | 80 ) |
77 window.addEventListener("keydown", self.on_key_down, True) | 81 window.addEventListener("keydown", self.on_key_down, True) |
78 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) |
79 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) |
80 self.swiper.on("slideChange", self.on_slide_change) | 84 self.swiper.on("slideChange", self.on_slide_change) |
81 self.swiper.on("click", self.on_click) | 85 self.swiper.on("click", self.on_click) |
86 self.swiper.on("doubleTap", self.on_double_tap) | |
82 self.on_slide_change() | 87 self.on_slide_change() |
83 self.fullscreen(True) | 88 self.fullscreen(True) |
84 | 89 |
85 def add_slide(self, slide_elt): | 90 def add_slide(self, elt, item_data=None): |
91 slide_elt = html.DIV(Class="swiper-slide") | |
92 zoom_cont_elt = html.DIV(Class="swiper-zoom-container") | |
93 slide_elt <= zoom_cont_elt | |
94 zoom_cont_elt <= elt | |
95 slide_elt._item = item_data | |
86 self.swiper.appendSlide([slide_elt]) | 96 self.swiper.appendSlide([slide_elt]) |
87 self.swiper.update() | 97 self.swiper.update() |
88 | 98 |
89 def quit(self): | 99 def quit(self): |
90 # we unhide | 100 # we unhide |
148 # this avoid double tap side effect | 158 # this avoid double tap side effect |
149 if self.click_timer is None: | 159 if self.click_timer is None: |
150 self.click_timer = timer.set_timeout( | 160 self.click_timer = timer.set_timeout( |
151 lambda: self.toggle_hide_controls(evt), 300) | 161 lambda: self.toggle_hide_controls(evt), 300) |
152 | 162 |
163 def on_double_tap(self, evt): | |
164 evt.stopPropagation() | |
165 evt.preventDefault() | |
166 if self.click_timer is not None: | |
167 timer.clear_timeout(self.click_timer) | |
168 self.click_timer = None | |
169 if self.swiper.zoom.scale != 1: | |
170 self.swiper.zoom.toggle() | |
171 else: | |
172 # "in" is reserved in Python, so we call it using dict syntax | |
173 self.swiper.zoom["in"]() | |
174 | |
153 def on_close(self, evt): | 175 def on_close(self, evt): |
154 evt.stopPropagation() | 176 evt.stopPropagation() |
155 evt.preventDefault() | 177 evt.preventDefault() |
156 self.quit() | 178 self.quit() |
157 | 179 |