diff --git a/public/s/js/f0ckm.js b/public/s/js/f0ckm.js index 9c7b8ef..33b1561 100644 --- a/public/s/js/f0ckm.js +++ b/public/s/js/f0ckm.js @@ -2167,12 +2167,6 @@ window.cancelAnimFrame = (function () { const currentScroll = window.scrollY; - // Immediately fade out the current main content to provide a clean slate for the next page - if (main) { - main.classList.add('grid-transition'); - main.classList.remove('show'); - } - // Save scroll position for the current page before we leave it (only for new navigations) if (!options.skipPush) { const currentState = history.state || {}; @@ -2215,19 +2209,19 @@ window.cancelAnimFrame = (function () { return loadItemAjax(url, replace, options); } - - // Show loading indicator immediately — before cache check so it's visible on cache-hit restores too - if (navbar) navbar.classList.add('pbwork'); - - // Check for cached grid (Index/Grid Only) - RESTORE EARLY to avoid pagination/layout destruction. - // The cache is checked on ANY grid navigation (not just popstate/skipPush), so clicking the - // navbar brand from an item view restores the grid instantly without re-fetching. + // ── Cache check MUST come before any DOM mutations (fade-out, pbwork) ────── + // Doing DOM mutations before the cache check caused IntersectionObserver to + // fire for ALL cached thumbnails simultaneously when they re-entered the + // viewport, loading them all at once instead of progressively. if (isGrid && !options.skipCache) { const targetCacheKey = urlObj.pathname + urlObj.search; if (gridCacheMap.has(targetCacheKey)) { const cache = gridCacheMap.get(targetCacheKey); // Keep cache alive — it is already cleared on mode/filter changes (gridCacheMap.clear()). + // Show progress bar for the brief moment of DOM swap + if (navbar) navbar.classList.add('pbwork'); + stopMedia(); // Instant fade out background canvas (from item view) @@ -2361,6 +2355,14 @@ window.cancelAnimFrame = (function () { const hash = new URL(url, window.location.origin).hash; + // Fade out current main content — only for full fetches (cache hits return early above). + // Doing this before the cache check caused IntersectionObserver to fire for ALL cached + // thumbnails at once when they re-entered the viewport after the DOM was mutated. + if (main) { + main.classList.add('grid-transition'); + main.classList.remove('show'); + } + // Show loading indicator if (navbar) navbar.classList.add("pbwork");