intersection observer multiple elements code example
Example: intersection observer multiple elements
const myImgs = document.querySelectorAll('.animate-me');
observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.intersectionRatio > 0) {
console.log('in the view');
} else {
console.log('out of view');
}
});
});
myImgs.forEach(image => {
observer.observe(image);
});