add animation, stop automatic slideshow when interacted with

This commit is contained in:
2024-02-01 23:52:53 +01:00
parent 132828389b
commit 8c1546ef7f
3 changed files with 22 additions and 2 deletions

View File

@@ -30,13 +30,28 @@ $gap: var(--gap);
} }
.snap-slideshow { .snap-slideshow {
// 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;
} }
} }
// Animation
.snap-slideshow .snap-image,
.snap-lightbox .snap-lightbox-inner {
animation: 1s fade;
@keyframes fade {
from {
opacity: .4
}
to {
opacity: 1
}
}
}
.snap-lightbox { .snap-lightbox {
/** Default lightbox to hidden */ /** Default lightbox to hidden */
display: none; display: none;
@@ -180,6 +195,7 @@ $gap: var(--gap);
// Position arrows for left/right // Position arrows for left/right
.snap-prev { .snap-prev {
left: 0; left: 0;
.snap-lightbox & span { .snap-lightbox & span {
left: 0.5%; left: 0.5%;
} }
@@ -187,6 +203,7 @@ $gap: var(--gap);
.snap-next { .snap-next {
right: 0; right: 0;
.snap-lightbox & span { .snap-lightbox & span {
right: 0.5%; right: 0.5%;
} }

View File

@@ -39,7 +39,7 @@
{{ else if eq $mode "slideshow" }} {{ else if eq $mode "slideshow" }}
{{ partial "slideshow" (dict "imgs" $imgs "galno" $galno) }} {{ partial "slideshow" (dict "imgs" $imgs "galno" $galno) }}
{{/* Set autorotate timer for slideshow */}} {{/* Set autorotate timer for slideshow */}}
<script>setInterval(moveSlideshowItem, 5000, {{ $galno }}, 1);</script> <script>const autoSlideshow = setInterval(moveSlideshowItem, 5000, {{ $galno }}, 1);</script>
{{ end }} {{ end }}
{{/* The Modal/Lightbox */}} {{/* The Modal/Lightbox */}}

View File

@@ -27,6 +27,9 @@ function moveLightboxItem(id, n) {
// Next/previous controls for slideshow // Next/previous controls for slideshow
function moveSlideshowItem(id, n) { function moveSlideshowItem(id, n) {
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
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