let observer = new IntersectionObserver((entries, observer) => { entries.forEach(entry => { if(entry.isIntersecting){ entry.target.classList.add('element-show'); observer.unobserve(entry.target); } }); }, {rootMargin: "3% 0px"}); document.querySelectorAll('section .block__img').forEach((el) => {observer.observe(el)});