Mercurial > libervia-web
diff libervia/pages/_browser/slideshow.py @ 1311:9948598e7ec0
browser (slideshow): show slideshow in fullscreen
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 Aug 2020 16:47:24 +0200 |
parents | 9e356f8eb62c |
children | 39a87d9099c4 |
line wrap: on
line diff
--- a/libervia/pages/_browser/slideshow.py Sat Aug 01 16:47:24 2020 +0200 +++ b/libervia/pages/_browser/slideshow.py Sat Aug 01 16:47:24 2020 +0200 @@ -80,6 +80,7 @@ self.swiper.on("slideChange", self.on_slide_change) self.swiper.on("click", self.on_click) self.on_slide_change() + self.fullscreen(True) def add_slide(self, slide_elt): self.swiper.appendSlide([slide_elt]) @@ -95,6 +96,30 @@ self.swiper.destroy(True, True) self.swiper = None + def fullscreen(self, active=None): + """Activate/desactivate fullscreen + + @param acvite: can be: + - True to activate + - False to desactivate + - Auto to switch fullscreen mode + """ + try: + fullscreen_elt = document.fullscreenElement + request_fullscreen = self.slideshow_elt.requestFullscreen + except AttributeError: + print("fullscreen is not available on this browser") + else: + if active is None: + active = fullscreen_elt != None + if active: + request_fullscreen() + else: + try: + document.exitFullscreen() + except AttributeError: + print("exitFullscreen not available on this browser") + def on_key_down(self, evt): if evt.key == 'Escape': self.quit()