Files
mantelzorgwoning.info/layouts/partials/page-transition.html
2025-12-05 09:15:15 +01:00

99 lines
2.6 KiB
HTML

<style>
:root{
--wipe-duration: .2s;
--wipe-ease: cubic-bezier(.22,.61,.36,1);
--wipe-color: #fff;
}
.wipe-overlay{
position: fixed; inset: 0;
background: var(--wipe-color);
z-index: 2147483647;
pointer-events: none;
transform: translateX(0);
transition: transform var(--wipe-duration) ease-in-out;
}
.wipe-overlay.no-trans{ transition: none; }
/* Tijdens reveal: schuif naar rechts uit beeld */
.wipe-overlay.is-revealing{ transform: translateX(100%); }
/* Bij binnenkomen nieuwe pagina: start links buiten beeld, schuif naar binnen */
.wipe-overlay.pre-enter{ transform: translateX(-100%); }
.wipe-overlay.is-covering{ transform: translateX(0); }
@media (prefers-reduced-motion: reduce){
.wipe-overlay{
transition: none !important;
transform: translateX(100%) !important;
}
}
</style>
<div class="wipe-overlay no-trans" id="wipe"></div>
<script>
(function () {
var wipe = document.getElementById('wipe');
if (!wipe) return;
function startReveal(){
wipe.classList.remove('no-trans');
requestAnimationFrame(function(){
wipe.classList.add('is-revealing');
});
}
window.addEventListener('pageshow', function () {
wipe.classList.add('no-trans');
wipe.classList.remove('pre-enter','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);
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();
wipe.classList.add('no-trans');
wipe.classList.remove('is-revealing','is-covering');
wipe.classList.add('pre-enter');
void wipe.offsetHeight;
wipe.classList.remove('no-trans');
wipe.classList.remove('pre-enter');
wipe.classList.add('is-covering');
var go = function () {
wipe.removeEventListener('transitionend', go);
window.location.href = a.href;
};
wipe.addEventListener('transitionend', go);
}, { capture: true });
})();
</script>