Animationen sind ganz toll und gar kein krampf :D

This commit is contained in:
2023-11-16 22:05:00 +01:00
parent 5d8d3f1f2f
commit a4e6cc4518
8 changed files with 95 additions and 7 deletions

View File

@ -0,0 +1,19 @@
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();
}