From 00ccc149122bc7160ce812d653cd5f8969b9422d Mon Sep 17 00:00:00 2001 From: Donovan G Date: Thu, 30 Jul 2026 23:23:25 -0400 Subject: [PATCH] Refactor navigation transition event handling My original commit was missing some code to fix the cache bug. --- js/demo.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/demo.js b/js/demo.js index 525b67c..d7ac53a 100644 --- a/js/demo.js +++ b/js/demo.js @@ -15,7 +15,14 @@ const current = navdemos.findIndex(el => el.classList.contains('demo--current')); const navigate = (linkEl) => { document.body.classList.remove('render'); - document.body.addEventListener('transitionend', () => window.location = linkEl.href); + + document.body.addEventListener( + 'transitionend', + () => { + window.location.href = linkEl.href; + }, + { once: true } + ); }; navdemos.forEach(link => link.addEventListener('click', (ev) => { ev.preventDefault(); @@ -39,4 +46,8 @@ document.body.classList.remove('loading'); document.body.classList.add('imgloaded'); }); + // fixes the navigation cache bug when the user presses "back". + window.addEventListener('pageshow', () => { + document.body.classList.add('render'); + }); }