fix(web): лента миниатюр следует за текущим фото в просмотре
При переходе стрелками влево/вправо активная миниатюра нижней ленты уходила за край и оставалась невидимой. Теперь лента прокручивается к текущему фото, удерживая его плитку в поле зрения.
This commit is contained in:
@@ -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'}"
|
||||
|
||||
Reference in New Issue
Block a user