Lachenzelg/assets/js/transition.js

27 lines
875 B
JavaScript
Raw Permalink Normal View History

2025-01-07 03:02:25 +01:00
document.addEventListener("DOMContentLoaded", function() {
const links = document.querySelectorAll('a');
links.forEach(link => {
link.addEventListener('click', function(event) {
const href = this.getAttribute('href');
if (href && href !== '#') {
event.preventDefault();
document.body.classList.add('page-transition-exit');
setTimeout(() => {
window.location.href = href;
}, 200); // Zeit, die der CSS-Übergang benötigt (0.5s)
}
});
});
window.addEventListener('load', function() {
document.body.classList.add('page-transition-enter');
setTimeout(() => {
document.body.classList.remove('page-transition-enter');
}, 200); // Zeit, die der CSS-Übergang benötigt (0.5s)
});
});