fix(web): лента миниатюр следует за текущим фото в просмотре

При переходе стрелками влево/вправо активная миниатюра нижней ленты уходила
за край и оставалась невидимой. Теперь лента прокручивается к текущему фото,
удерживая его плитку в поле зрения.
This commit is contained in:
iu
2026-10-20 22:06:20 +03:00
parent 35f84399bc
commit 0a9e5274cf
2 changed files with 26 additions and 1 deletions
+19
View File
@@ -124,6 +124,24 @@
return () => document.removeEventListener('fullscreenchange', onFs);
});
$effect(() => {
// Лента миниатюр следует за текущим фото: активная плитка всегда в поле зрения.
const i = index;
const count = photos.length;
const strip = bottomEl;
if (!strip || !count) return;
const cell = strip.querySelectorAll<HTMLElement>('[data-strip-cell]')[i];
if (!cell) return;
const pad = 8;
const cellRect = cell.getBoundingClientRect();
const stripRect = strip.getBoundingClientRect();
if (cellRect.left < stripRect.left + pad) {
strip.scrollLeft -= stripRect.left + pad - cellRect.left;
} else if (cellRect.right > stripRect.right - pad) {
strip.scrollLeft += cellRect.right - (stripRect.right - pad);
}
});
const topClass = $derived(
`pointer-events-none absolute inset-x-0 top-0 z-30 flex items-center justify-between gap-1 bg-transparent px-2 py-0.5 transition-transform duration-200 ${isFullscreen && !showTop ? '-translate-y-full' : 'translate-y-0'}`
);
@@ -554,6 +572,7 @@
{#each photos as photo, i (photo.id)}
<button
type="button"
data-strip-cell
class="group h-16 w-16 shrink-0 overflow-hidden rounded border {i === index
? 'border-primary'
: 'border-border'}"