Merge branch 'develop' of https://gitea.stommer.de/Lars/fewo-stommer into develop
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
This commit is contained in:
commit
9f3501e045
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;
|
||||
};
|
||||
|
||||
// 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) => {
|
||||
index = (position + series.length) % series.length;
|
||||
const link = series[index];
|
||||
const thumbnail = thumbnailOf(link);
|
||||
fit();
|
||||
image.src = thumbnail?.currentSrc || link.href;
|
||||
image.alt = 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) => {
|
||||
if (series.length < 2) {
|
||||
return;
|
||||
}
|
||||
show(index + step);
|
||||
if (!reducedMotion()) {
|
||||
image.animate([{ opacity: 0, transform: `translateX(${step * 2.5}rem)` }, { opacity: 1, transform: 'none' }], { duration: 320, easing: ease });
|
||||
}
|
||||
const target = (index + step + series.length) % series.length;
|
||||
const ticket = ++browsing;
|
||||
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 thumbnail = thumbnailOf(series[index] ?? lightbox);
|
||||
const start = !reducedMotion() && thumbnail && visible(thumbnail) ? fromThumbnail(thumbnail) : null;
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<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="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>
|
||||
</figure>
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user