From af4eb2bde466721eb486e19933279727598f268d Mon Sep 17 00:00:00 2001 From: Nikola Ganchev Date: Tue, 19 Sep 2023 22:09:07 +0300 Subject: [PATCH] Allow gallery images to be fullscreen opened --- src/lib/{NavClose.svelte => Close.svelte} | 0 src/lib/Gallery.svelte | 90 ++++++++++++++++++++++- src/lib/Navbar.svelte | 4 +- 3 files changed, 89 insertions(+), 5 deletions(-) rename src/lib/{NavClose.svelte => Close.svelte} (100%) diff --git a/src/lib/NavClose.svelte b/src/lib/Close.svelte similarity index 100% rename from src/lib/NavClose.svelte rename to src/lib/Close.svelte diff --git a/src/lib/Gallery.svelte b/src/lib/Gallery.svelte index 3906fe3..17fc1ae 100644 --- a/src/lib/Gallery.svelte +++ b/src/lib/Gallery.svelte @@ -4,6 +4,7 @@ import { linear } from "svelte/easing"; import ArrowLeft from "$lib/ArrowLeft.svelte"; import ArrowRight from "$lib/ArrowRight.svelte"; + import Close from "$lib/Close.svelte"; export let images; export let arrowColor; @@ -13,6 +14,7 @@ let selectedImageIndex = 0 let elements = []; + let fullscreenShown = false; const scrollConfig = { behavior: 'smooth', @@ -48,12 +50,38 @@ elements[selectedImageIndex].scrollIntoView(scrollConfig) }); } + + const openFullscreen = () => { + fullscreenShown = true + document.body.classList.add("no-scroll") + } + + const closeFullscreen = () => { + fullscreenShown = false + document.body.classList.remove("no-scroll") + }
- {images[selectedImageIndex].image.alt} + +
e.stopPropagation()}> + {images[selectedImageIndex].image.alt} +
{images[selectedImageIndex].image.alt}
+
+ +