Reapply "uga aga pipi kaka"

This reverts commit 3856f752bd.
This commit is contained in:
2026-07-12 21:15:17 +02:00
parent 656f3ea4b1
commit db44e04dba

View File

@@ -2227,12 +2227,15 @@ window.cancelAnimFrame = (function () {
} }
// Check for cached grid (Index/Grid Only) - RESTORE EARLY to avoid pagination/layout destruction // Check for cached grid (Index/Grid Only) - RESTORE EARLY to avoid pagination/layout destruction.
if (isGrid && options.skipPush) { // We check the cache for ANY grid navigation (not just skipPush/popstate) so that clicking the
// logo or any other link back to a previously-viewed grid page is instant — no blank thumbs,
// no re-fetch. The cached DOM node already has all background-images set on the thumb elements.
if (isGrid) {
const targetCacheKey = urlObj.pathname + urlObj.search; const targetCacheKey = urlObj.pathname + urlObj.search;
if (gridCacheMap.has(targetCacheKey)) { if (gridCacheMap.has(targetCacheKey)) {
const cache = gridCacheMap.get(targetCacheKey); const cache = gridCacheMap.get(targetCacheKey);
gridCacheMap.delete(targetCacheKey); // Consume cache gridCacheMap.delete(targetCacheKey); // Consume cache (one-shot restore)
stopMedia(); stopMedia();
@@ -2281,6 +2284,12 @@ window.cancelAnimFrame = (function () {
} }
} }
// Push URL to history for forward navigations (logo click etc.) so the back button works.
// skipPush navigations (popstate) must NOT push or we'd create a double history entry.
if (!options.skipPush) {
history.pushState({}, '', url);
}
// Restore Scroll Position // Restore Scroll Position
requestAnimationFrame(() => window.scrollTo(0, cache.scroll)); requestAnimationFrame(() => window.scrollTo(0, cache.scroll));
@@ -3706,6 +3715,18 @@ window.cancelAnimFrame = (function () {
targetUrl = targetUrl.replace(/[?&]strict=1/, '').replace(/[?&]$/, ''); targetUrl = targetUrl.replace(/[?&]strict=1/, '').replace(/[?&]$/, '');
} }
// If we're already on this exact page and there's no cached grid to restore,
// just scroll to top — no point wiping and re-fetching the current grid.
const _targetBase = targetUrl.split('#')[0];
const _currentBase = window.location.href.split('#')[0];
if (_targetBase === _currentBase && !anyLink.hash) {
const _cacheKey = new URL(targetUrl, window.location.origin).pathname + new URL(targetUrl, window.location.origin).search;
if (!gridCacheMap.has(_cacheKey)) {
window.scrollTo({ top: 0, behavior: 'smooth' });
return false;
}
}
const parts = pathname.split('/').filter(Boolean); const parts = pathname.split('/').filter(Boolean);
const isItemLink = !pathname.match(/\/p\//) && ( const isItemLink = !pathname.match(/\/p\//) && (
pathname.match(/^\/\d+/) || pathname.match(/^\/\d+/) ||