KI-Kunst-Kirsten-Kloeckner/KIKunstKirstenKlöckner/wwwroot/js/animator.js

20 lines
567 B
JavaScript
Raw Normal View History

function initScrollAnimations(elements) {
function checkVisibility(element) {
const rect = element.getBoundingClientRect();
return rect.top < window.innerHeight && rect.bottom >= 0;
}
function animateElements() {
elements.forEach(element => {
if (checkVisibility(element)) {
element.classList.add('visible');
}
});
}
window.addEventListener('scroll', animateElements);
// Initialer Aufruf für den Fall, dass Elemente bereits sichtbar sind
animateElements();
}