Galerie: kein Springen beim Blaettern, Vergleich ohne Pfeile an den Beschriftungen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
- Lightbox: feste Bildgroesse aus dem Seitenverhaeltnis, beim Blaettern wird das grosse Foto erst geladen und dann eingeblendet - Seebad-Vergleich: Pfeile neben Sommer/Winter entfernt (passten nicht zur Ziehrichtung) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
545008baab
commit
a1fc4f7fef
2 files changed
+31
-6
No files matched your search
@@ -38,10 +38,21 @@ if (lightbox && typeof lightbox.showModal === 'function') {
|
|||||||
return rect.bottom > 0 && rect.top < window.innerHeight && rect.width > 0;
|
return rect.bottom > 0 && rect.top < window.innerHeight && rect.width > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The image gets its final size from the photo's aspect ratio, so swapping the thumbnail for the large file
|
||||||
|
// (or browsing to the next photo) never makes it jump between sizes.
|
||||||
|
const fit = () => {
|
||||||
|
const thumbnail = thumbnailOf(series[index]);
|
||||||
|
const ratio = thumbnail?.naturalWidth ? thumbnail.naturalWidth / thumbnail.naturalHeight : 3 / 2;
|
||||||
|
const width = Math.min(window.innerWidth * 0.94, window.innerHeight * 0.84 * ratio);
|
||||||
|
image.style.width = `${width}px`;
|
||||||
|
image.style.height = `${width / ratio}px`;
|
||||||
|
};
|
||||||
|
|
||||||
const show = (position) => {
|
const show = (position) => {
|
||||||
index = (position + series.length) % series.length;
|
index = (position + series.length) % series.length;
|
||||||
const link = series[index];
|
const link = series[index];
|
||||||
const thumbnail = thumbnailOf(link);
|
const thumbnail = thumbnailOf(link);
|
||||||
|
fit();
|
||||||
image.src = thumbnail?.currentSrc || link.href;
|
image.src = thumbnail?.currentSrc || link.href;
|
||||||
image.alt = link.dataset.alt ?? '';
|
image.alt = link.dataset.alt ?? '';
|
||||||
caption.textContent = link.dataset.caption || link.dataset.alt || '';
|
caption.textContent = link.dataset.caption || link.dataset.alt || '';
|
||||||
@@ -55,16 +66,30 @@ if (lightbox && typeof lightbox.showModal === 'function') {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Browsing waits (briefly) for the large file of the next photo, then fades it in; no thumbnail flashes in between.
|
||||||
|
let browsing = 0;
|
||||||
const browse = (step) => {
|
const browse = (step) => {
|
||||||
if (series.length < 2) {
|
if (series.length < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
show(index + step);
|
const target = (index + step + series.length) % series.length;
|
||||||
if (!reducedMotion()) {
|
const ticket = ++browsing;
|
||||||
image.animate([{ opacity: 0, transform: `translateX(${step * 2.5}rem)` }, { opacity: 1, transform: 'none' }], { duration: 320, easing: ease });
|
const large = new Image();
|
||||||
}
|
large.src = series[target].href;
|
||||||
|
const ready = Promise.race([large.decode().catch(() => {}), new Promise((resolve) => setTimeout(resolve, 600))]);
|
||||||
|
ready.then(() => {
|
||||||
|
if (ticket !== browsing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
show(target);
|
||||||
|
if (!reducedMotion()) {
|
||||||
|
image.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 260, easing: 'ease-out' });
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => { if (lightbox.open) fit(); });
|
||||||
|
|
||||||
const close = () => {
|
const close = () => {
|
||||||
const thumbnail = thumbnailOf(series[index] ?? lightbox);
|
const thumbnail = thumbnailOf(series[index] ?? lightbox);
|
||||||
const start = !reducedMotion() && thumbnail && visible(thumbnail) ? fromThumbnail(thumbnail) : null;
|
const start = !reducedMotion() && thumbnail && visible(thumbnail) ? fromThumbnail(thumbnail) : null;
|
||||||
|
|||||||
@@ -28,9 +28,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<figcaption class="mt-3 flex items-baseline justify-between gap-6 font-display text-[1.5rem] leading-tight">
|
<figcaption class="mt-3 flex items-baseline justify-between gap-6 font-display text-[1.5rem] leading-tight">
|
||||||
<span class="flex items-center gap-2"><x-heroicon-o-arrow-long-left class="size-6 text-accent" aria-hidden="true" />{{ $firstLabel }}</span>
|
<span>{{ $firstLabel }}</span>
|
||||||
<span class="hidden text-base text-muted sm:inline" aria-hidden="true">Linie ziehen zum Vergleichen</span>
|
<span class="hidden text-base text-muted sm:inline" aria-hidden="true">Linie ziehen zum Vergleichen</span>
|
||||||
<span class="flex items-center gap-2">{{ $secondLabel }}<x-heroicon-o-arrow-long-right class="size-6 text-accent" aria-hidden="true" /></span>
|
<span>{{ $secondLabel }}</span>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in new issue
Block a user