Animationen sind ganz toll und gar kein krampf :D
This commit is contained in:
19
KIKunstKirstenKlöckner/wwwroot/js/animator.js
Normal file
19
KIKunstKirstenKlöckner/wwwroot/js/animator.js
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user