toggle class on scroll
const images = document.querySelectorAll(".js-scroll");
observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.intersectionRatio > 0) {
entry.target.classList.add("class-1");
} else {
entry.target.classList.remove("class-1");
}
});
});
images.forEach((image) => {
observer.observe(image);
});
pure JavaScript
/*Rogi Network*/
/*+923022020318*/
/*roginetwork.com*/