const ratio = 0.5; const options = { root: null, rootMargin: '0px', threshold: ratio } const callback = function (entries, observer) { entries.forEach(entry => { console.log(entry.intersectionRatio) if (entry.intersectionRatio > ratio) { document.querySelector('.revealForm').classList.add('show') observer.unobserve(entry.target); } }); } console.log(options.threshold) let observer = new IntersectionObserver(callback, options) observer.observe(document.querySelector('.revealForm'))