let fullWidthImageOptions = { root: null, rootMargin: "0px", threshold: 0, }; let fullWidthImageTarget = document.querySelector(".full-width-image"); let fullWidthImageOptionsCallback = (entries, observer) => { entries.forEach(entry => { if (entry.isIntersecting) { document.querySelector('.header .inner-container').classList.add('header-white'); } else { document.querySelector('.header .inner-container').classList.remove('header-white'); } }); }; let fullWidthImageObserver = new IntersectionObserver(fullWidthImageOptionsCallback, fullWidthImageOptions); fullWidthImageObserver.observe(fullWidthImageTarget);