const container = document.querySelector('.container');
const line = document.querySelector('.invisibility');
const marginBottom = line.getBoundingClientRect().top - container.getBoundingClientRect().bottom;
const options = {
root: document.querySelector('.container'),
rootMargin: `0px 0px ${marginBottom}px 0px`,
threshold: 0
}
const callback = function(entries, observer) {
entries.forEach((entry) => {
entry.target.style.background = entry.isIntersecting ? 'green' : 'red';
});
};
const observer = new IntersectionObserver(callback, options);
container.querySelectorAll('.item').forEach(item => {
observer.observe(item);
});