Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 300896dd authored by Pierre Jarriges's avatar Pierre Jarriges
Browse files

images-courasel toggle fullscreen escape key

parent 1c958d90
No related branches found
No related tags found
1 merge request!4images-courasel toggle fullscreen escape key
{ {
"name": "kuadrado-website", "name": "kuadrado-website",
"version": "1.0.4", "version": "1.1.0",
"description": "Presentation website of Kuadrado Software", "description": "Presentation website of Kuadrado Software",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {
......
...@@ -10,6 +10,7 @@ class ImageCarousel { ...@@ -10,6 +10,7 @@ class ImageCarousel {
}; };
this.RUN_INTERVAL = 5000; this.RUN_INTERVAL = 5000;
this.props.images.length > 1 && this.run(); this.props.images.length > 1 && this.run();
this.toggle_fullscreen = this.toggle_fullscreen.bind(this);
} }
run() { run() {
...@@ -33,6 +34,19 @@ class ImageCarousel { ...@@ -33,6 +34,19 @@ class ImageCarousel {
this.refresh(); this.refresh();
} }
toggle_fullscreen() {
this.state.fullscreen = !this.state.fullscreen;
document.getElementById(this.id).classList.toggle("fullscreen");
document.body.style.overflow = this.state.fullscreen ? "hidden" : "initial";
if (this.state.fullscreen) {
window.addEventListener("keydown", this.toggle_fullscreen);
} else {
window.removeEventListener("keydown", this.toggle_fullscreen);
}
}
refresh() { refresh() {
obj2htm.subRender(this.render_image(), document.getElementById(this.id + "-img-element"), { obj2htm.subRender(this.render_image(), document.getElementById(this.id + "-img-element"), {
mode: "replace", mode: "replace",
...@@ -79,9 +93,7 @@ class ImageCarousel { ...@@ -79,9 +93,7 @@ class ImageCarousel {
contents: this.state.fullscreen ? "" : "", contents: this.state.fullscreen ? "" : "",
onclick: e => { onclick: e => {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
this.state.fullscreen = !this.state.fullscreen; this.toggle_fullscreen();
document.getElementById(this.id).classList.toggle("fullscreen");
document.body.style.overflow = this.state.fullscreen ? "hidden" : "initial";
this.refresh(); this.refresh();
}, },
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment