{
const root = example1.querySelector('.frame');
const rootMargin = rootMarginExample1;
const sectionEls = [...root.querySelectorAll('.section')];
function observerCallback(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
root.classList.add('in-section');
} else {
root.classList.remove('in-section');
}
});
}
const options = {
root,
rootMargin,
};
const observer = new IntersectionObserver(observerCallback, options);
sectionEls.forEach(el => observer.observe(el));
}