feat(web): сохранять размер миниатюр при скрытых боковых панелях
В скрытом режиме панели больше не растягивают плитки: сетка пересчитывает число колонок так, чтобы размер миниатюры остался прежним, а в строке помещалось больше фото. Каркас публикует ширину, которую занимают панели в текущей раскладке (рейл на широких экранах, панель на сверхшироких), сетка использует её для пересчёта, а навигация курсора стрелками учитывает реальное число колонок.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Icon from './Icon.svelte';
|
||||
import { density } from '$lib/stores/density.svelte';
|
||||
import { grid } from '$lib/stores/grid.svelte';
|
||||
import { isPanoTag } from '$lib/pano';
|
||||
import type { Photo } from '$lib/types';
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
const GAP_PX = 8;
|
||||
let gridWidth = $state(0);
|
||||
|
||||
$effect(() => {
|
||||
grid.width = gridWidth;
|
||||
});
|
||||
|
||||
// Offer every variant the photo actually has; the backend generates the
|
||||
// medium variant asynchronously, so an incomplete set must still render.
|
||||
function srcsetFor(photo: Photo): string {
|
||||
@@ -44,7 +48,7 @@
|
||||
|
||||
const sizes = $derived(
|
||||
gridWidth > 0
|
||||
? `${Math.max(1, Math.round((gridWidth - (density.cols - 1) * GAP_PX) / density.cols))}px`
|
||||
? `${Math.max(1, Math.round((gridWidth - (grid.cols - 1) * GAP_PX) / grid.cols))}px`
|
||||
: undefined
|
||||
);
|
||||
|
||||
@@ -76,7 +80,7 @@
|
||||
<ul
|
||||
class="grid gap-2"
|
||||
bind:clientWidth={gridWidth}
|
||||
style="grid-template-columns: repeat({density.cols}, minmax(0, 1fr));"
|
||||
style="grid-template-columns: repeat({grid.cols}, minmax(0, 1fr));"
|
||||
>
|
||||
{#each photos as photo, i (photo.id)}
|
||||
<li>
|
||||
|
||||
Reference in New Issue
Block a user