blob: 6c2fa7ca2bf200224c1bdbbb466ab11c73a399e3 [file] [log] [blame]
let animations = undefined;
class AnimationManager {
constructor()
{
this.setupObserver();
let targets = document.querySelectorAll('.animation-container');
for (let target of targets) {
this.observer.observe(target);
}
}
setupObserver()
{
this.observer = new IntersectionObserver((observations) => {
this.intersectionsChanged(observations);
});
}
intersectionsChanged(observations)
{
for (let obs of observations) {
if (obs.isIntersecting)
obs.target.classList.add('visible');
else
obs.target.classList.remove('visible');
}
}
};
window.addEventListener('load', () => {
animations = new AnimationManager();
}, false);