add slideshow functionality, adapt JS, adapt CSS

This commit is contained in:
2024-02-01 17:30:46 +01:00
parent 10ec813ac3
commit bd4fe8de10
5 changed files with 87 additions and 28 deletions

View File

@@ -2,6 +2,17 @@
{{- $.Page.Scratch.Add "gallerycount" 1 -}}
{{ $galno := $.Page.Scratch.Get "gallerycount" }}
{{/* Load CSS/JS and make sure it is only loaded once */}}
{{- if eq ($.Page.Scratch.Get "gallerycount") 1 }}
{{- with resources.Get "scss/snap-gallery.scss" | toCSS }}
<link rel="stylesheet" href="{{ .RelPermalink }}" crossorigin="anonymous">
{{- end }}
<script src="/js/snap-gallery.js"></script>
{{ end }}
{{/* Initialise index of this gallery */}}
<script>imageIndex[{{ $galno }}] = 1;</script>
{{/* Initialise variables holding image paths */}}
{{ $imgs := slice }}
@@ -19,16 +30,17 @@
{{ end }}
{{ end }}
{{/* Visible images in gallery mode */}}
{{/* Visible images in separate modes */}}
{{ $mode := default "gallery" .Params.mode }}
{{/* Gallery mode */}}
{{ if eq $mode "gallery" }}
{{ partial "gallery" (dict "columns" .Params.columns "minwidth" .Params.minwidth "imgs" $imgs "galno" $galno) }}
{{/* Slideshow mode */}}
{{ else if eq $mode "slideshow" }}
{{ partial "slideshow" (dict "imgs" $imgs "galno" $galno) }}
{{/* Set autorotate timer for slideshow */}}
<script>setInterval(moveSlideshowItem, 5000, {{ $galno }}, 1);</script>
{{ end }}
{{/* The Modal/Lightbox */}}
{{ partial "lightbox" (dict "galno" $galno "imgs" $imgs) }}
{{/* Load CSS/JS and make sure it is only loaded once */}}
{{- if eq ($.Page.Scratch.Get "gallerycount") 1 }}
{{- with resources.Get "scss/snap-gallery.scss" | toCSS }}
<link rel="stylesheet" href="{{ .RelPermalink }}" crossorigin="anonymous">
{{- end }}
<script src="/js/snap-gallery.js"></script>
{{ end }}