102 lines
2.5 KiB
HTML
102 lines
2.5 KiB
HTML
<style>
|
|
:root{
|
|
--wipe-duration: .1s;
|
|
--wipe-ease: cubic-bezier(1,.22,.22,1);
|
|
--wipe-color: #fff;
|
|
}
|
|
|
|
.wipe-overlay{
|
|
position: fixed;
|
|
inset: 0;
|
|
background: var(--wipe-color);
|
|
z-index: 2147483647;
|
|
pointer-events: none;
|
|
opacity: 1;
|
|
transition: opacity var(--wipe-duration) var(--wipe-ease);
|
|
}
|
|
|
|
.wipe-overlay.no-trans{
|
|
transition: none;
|
|
}
|
|
|
|
/* Na pageload: fade naar transparant */
|
|
.wipe-overlay.is-revealing{
|
|
opacity: 0;
|
|
}
|
|
|
|
/* Bij navigatie: fade weer naar volledig zichtbaar */
|
|
.wipe-overlay.is-covering{
|
|
opacity: 1;
|
|
}
|
|
|
|
@media (prefers-reduced-motion: reduce){
|
|
.wipe-overlay{
|
|
transition: none !important;
|
|
opacity: 0 !important;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<div class="wipe-overlay no-trans" id="wipe"></div>
|
|
|
|
<script>
|
|
(function () {
|
|
var wipe = document.getElementById('wipe');
|
|
if (!wipe) return;
|
|
|
|
function startReveal(){
|
|
// overlay van 1 → 0 (fade-out)
|
|
wipe.classList.remove('no-trans');
|
|
requestAnimationFrame(function(){
|
|
wipe.classList.add('is-revealing');
|
|
wipe.classList.remove('is-covering');
|
|
});
|
|
}
|
|
|
|
// Bij binnenkomst pagina: reset + fade-out
|
|
window.addEventListener('pageshow', function () {
|
|
wipe.classList.add('no-trans');
|
|
wipe.classList.remove('is-covering', 'is-revealing');
|
|
requestAnimationFrame(startReveal);
|
|
});
|
|
|
|
function normPath(p){
|
|
if (!p) return '/';
|
|
p = p.replace(/\/index\.html?$/i, '/').replace(/\/+$/,'/');
|
|
return p || '/';
|
|
}
|
|
|
|
document.addEventListener('click', function (e) {
|
|
if (e.defaultPrevented) return;
|
|
|
|
var a = e.target.closest && e.target.closest('a');
|
|
if (!a) return;
|
|
|
|
var here = new URL(window.location.href);
|
|
var url = new URL(a.href, here);
|
|
|
|
// externe link / nieuwe tab / download → negeren
|
|
if (url.origin !== here.origin) return;
|
|
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
|
if (a.target === '_blank' || a.hasAttribute('download')) return;
|
|
|
|
var samePath = normPath(url.pathname) === normPath(here.pathname);
|
|
var sameSearch = url.search === here.search;
|
|
if (samePath && sameSearch) return;
|
|
|
|
e.preventDefault();
|
|
|
|
// reset naar transparant, dan fade naar opaque
|
|
wipe.classList.remove('no-trans', 'is-revealing');
|
|
void wipe.offsetHeight; // force reflow zodat transition altijd triggert
|
|
wipe.classList.add('is-covering');
|
|
|
|
var go = function () {
|
|
wipe.removeEventListener('transitionend', go);
|
|
window.location.href = a.href;
|
|
};
|
|
wipe.addEventListener('transitionend', go);
|
|
}, { capture: true });
|
|
})();
|
|
</script>
|