Complete rewrite #1

Merged
mxmehl merged 27 commits from refactoring into master 2024-02-07 22:17:50 +01:00
4 changed files with 17 additions and 7 deletions
Showing only changes of commit f8e99cdbda - Show all commits

View File

@@ -30,6 +30,9 @@ $gap: var(--gap);
} }
.snap-slideshow { .snap-slideshow {
width: var(--slideshow-width);
margin: auto;
// Hide all contained images except the first // Hide all contained images except the first
.snap-image:not(:first-child) { .snap-image:not(:first-child) {
display: none; display: none;

View File

@@ -1,6 +1,6 @@
{{ $imgs := .imgs }} {{ $imgs := .imgs }}
{{ $galno := .galno }} {{ $galno := .galno }}
<div class="snap-slideshow" id="snap-slideshow-{{ $galno }}" style="--columns:1;--min-width:0px;--gap:0px;"> <div class="snap-slideshow" id="snap-slideshow-{{ $galno }}" style="--columns:1;--min-width:0px;--gap:0px;--slideshow-width:{{ default "100%" .width }}">
{{ range $i, $img := $imgs }} {{ range $i, $img := $imgs }}
<div class="snap-image"> <div class="snap-image">
<div class="numbertext">{{ add $i 1 }} / {{ len $imgs }}</div> <div class="numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>

View File

@@ -37,9 +37,11 @@
{{ partial "gallery" (dict "columns" .Params.columns "minwidth" .Params.minwidth "imgs" $imgs "galno" $galno) }} {{ partial "gallery" (dict "columns" .Params.columns "minwidth" .Params.minwidth "imgs" $imgs "galno" $galno) }}
{{/* Slideshow mode */}} {{/* Slideshow mode */}}
{{ else if eq $mode "slideshow" }} {{ else if eq $mode "slideshow" }}
{{ partial "slideshow" (dict "imgs" $imgs "galno" $galno) }} {{ partial "slideshow" (dict "imgs" $imgs "galno" $galno "width" .Params.slideshowwidth) }}
{{/* Set autorotate timer for slideshow */}} {{/* Set autorotate timer for slideshow, if configured (default: yes) */}}
<script>const autoSlideshow = setInterval(moveSlideshowItem, 5000, {{ $galno }}, 1);</script> {{ if .Params.slideshowrotate }}
<script>const autoSlideshow = setInterval(moveSlideshowItem, {{ default 5000 .Params.slideshowrotate_timer }}, {{ $galno }}, 1, "auto");</script>
{{ end }}
{{ end }} {{ end }}
{{/* The Modal/Lightbox */}} {{/* The Modal/Lightbox */}}

View File

@@ -7,6 +7,9 @@ var imageIndex = {}
// Open the Lightbox // Open the Lightbox
function openLightbox(id) { function openLightbox(id) {
document.getElementById(lightbox_baseid + id).style.display = "block"; document.getElementById(lightbox_baseid + id).style.display = "block";
// Kill automatic slideshow when lightbox opened
clearInterval(autoSlideshow);
} }
// Close the Lightbox // Close the Lightbox
@@ -25,11 +28,13 @@ function moveLightboxItem(id, n) {
} }
// Next/previous controls for slideshow // Next/previous controls for slideshow
function moveSlideshowItem(id, n) { function moveSlideshowItem(id, n, mode) {
showItem(slideshow_baseid, id, imageIndex[id] += n, ".snap-image"); showItem(slideshow_baseid, id, imageIndex[id] += n, ".snap-image");
// Kill automatic slideshow once the slideshow has been moved // Kill automatic slideshow once the slideshow has been moved manually
if (mode !== "auto") {
clearInterval(autoSlideshow); clearInterval(autoSlideshow);
}
} }
// In the slideshow or lightbox, make a specific image visible, make others hidden // In the slideshow or lightbox, make a specific image visible, make others hidden