fix: prevent last gallery row from overflowing container
All checks were successful
Docker / build (release) Successful in 1m15s

This commit is contained in:
krek0 2026-08-30 03:44:10 +02:00
parent b57f9092aa
commit eeb2e1566f

View file

@ -43,10 +43,10 @@
const sumRatios = ratios.slice(start, end).reduce((a, b) => a + b, 0);
const totalSpacing = SPACING * (count - 1);
// Don't stretch the last row if it's not full
const rowHeight = isLastRow && count < 3
? TARGET_HEIGHT
: (containerWidth - totalSpacing) / sumRatios;
// Fill the container width, except for a last row that isn't full:
// it keeps the target height, but never wider than the container.
const fitHeight = (containerWidth - totalSpacing) / sumRatios;
const rowHeight = isLastRow ? Math.min(TARGET_HEIGHT, fitHeight) : fitHeight;
let left = PADDING;
for (let i = start; i < end; i++) {