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'); + }); }