Compare commits

...

1 Commits

Author SHA1 Message Date
c3935f1924 add caption on slideshow and lightbox 2024-02-07 21:59:15 +01:00
3 changed files with 42 additions and 16 deletions

View File

@@ -82,7 +82,12 @@ $gap: var(--gap);
/* stretch line height */ /* stretch line height */
height: 100%; height: 100%;
} }
}
// Disable cursor selection in lightbox and on slideshow, especially controls
.snap-lightbox,
.snap-slideshow {
user-select: none;
} }
// /* Click on the complete background closes the lightbox */ // /* Click on the complete background closes the lightbox */
@@ -123,17 +128,37 @@ $gap: var(--gap);
} }
} }
/* Number text (1/3 etc) */ /* Number text (1/3 etc) and captions*/
.snap-lightbox, .snap-numbertext {
.snap-slideshow { position: absolute;
user-select: none;
.numbertext {
color: #f2f2f2; color: #f2f2f2;
background-color: #000; background-color: #000;
font-size: 12px; font-size: 12px;
padding: 8px 12px; padding: 8px 12px;
}
.snap-caption {
bottom: 0;
color: #f2f2f2;
padding: 8px 0;
left: 10%;
width: 80%;
text-shadow: 1px 1px 10px #000;
font-weight: 700;
font-size: 1.1em;
text-align: center;
// As slideshow, position on picture on mid-screens and wider
.snap-slideshow & {
position: absolute; position: absolute;
@media screen and (max-width: 767px) {
display: none;
}
}
// In lightbox, always show below picture
.snap-lightbox & {
position: relative;
} }
} }

View File

@@ -3,13 +3,16 @@
<div class="snap-lightbox" id="snap-lightbox-{{ $galno }}"> <div class="snap-lightbox" id="snap-lightbox-{{ $galno }}">
{{- range $i, $img := $imgs }} {{- range $i, $img := $imgs }}
<div class="snap-lightbox-inner"> <div class="snap-lightbox-inner">
<div class="numbertext">{{ add $i 1 }} / {{ len $imgs }}</div> <div class="snap-numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>
<img <img
src="{{ relURL $img.src }}" src="{{ relURL $img.src }}"
{{ range $attr, $value := $img.html -}} {{ range $attr, $value := $img.html -}}
{{ safeHTMLAttr $attr }}={{ $value }} {{ safeHTMLAttr $attr }}={{ $value }}
{{ end -}} {{ end -}}
/> />
{{- with $img.html.title }}
<div class="snap-caption">{{ . }}</div>
{{- end }}
</div> </div>
{{- end -}} {{- end -}}
@@ -18,9 +21,4 @@
<a class="snap-prev" onclick="moveLightboxItem({{ $galno }}, -1)"><span>&#10094;</span></a> <a class="snap-prev" onclick="moveLightboxItem({{ $galno }}, -1)"><span>&#10094;</span></a>
<a class="snap-next" onclick="moveLightboxItem({{ $galno }}, 1)"><span>&#10095;</span></a> <a class="snap-next" onclick="moveLightboxItem({{ $galno }}, 1)"><span>&#10095;</span></a>
{{/* <!-- Caption text -->
<div class="caption-container">
<p id="caption"></p>
</div> */}}
</div> </div>

View File

@@ -3,7 +3,10 @@
<div class="snap-slideshow" id="snap-slideshow-{{ $galno }}" style="--columns:1;--min-width:0px;--gap:0px;--slideshow-width:{{ default "100%" .width }};--cursor:{{ .cursor }};--aspectratio:{{ safeCSS (default "16/10" .aspectratio) }};"> <div class="snap-slideshow" id="snap-slideshow-{{ $galno }}" style="--columns:1;--min-width:0px;--gap:0px;--slideshow-width:{{ default "100%" .width }};--cursor:{{ .cursor }};--aspectratio:{{ safeCSS (default "16/10" .aspectratio) }};">
{{- 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="snap-numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>
{{- with $img.html.title }}
<div class="snap-caption">{{ . }}</div>
{{- end }}
<img <img
src="{{ relURL $img.src }}" src="{{ relURL $img.src }}"
{{ range $attr, $value := $img.html -}} {{ range $attr, $value := $img.html -}}