prepared and gallery fixes

This commit is contained in:
2026-02-19 08:36:32 +01:00
parent 8935065af1
commit c30fa5a392
36 changed files with 1437 additions and 104 deletions

View File

@@ -230,12 +230,25 @@
var colCount = 1;
try {
var cols = window.getComputedStyle(grid).getPropertyValue('grid-template-columns');
if (cols) colCount = Math.max(1, cols.trim().split(/\s+/).length);
if (cols) {
var parts = cols.trim().split(/\s+/).filter(function (p) { return p.length > 0; });
colCount = Math.max(1, parts.length);
}
} catch (e) {
colCount = 1;
}
var refIndex = Math.max(0, cards.length - colCount);
if (cards.length === 0) {
if (trigger.parentNode) trigger.parentNode.removeChild(trigger);
grid.appendChild(trigger);
return;
}
// Compute the first index of the last row, then step back one row to
// place the trigger at the start of the penultimate row.
var lastRowStart = Math.floor((cards.length - 1) / colCount) * colCount;
var penultimateRowStart = Math.max(0, lastRowStart - colCount);
var refIndex = penultimateRowStart;
var ref = cards[refIndex] || null;
if (trigger.parentNode) trigger.parentNode.removeChild(trigger);