{ if (entries[0].boundingClientRect.y < 0) { headerEl.classList.remove('at-top') } else { headerEl.classList.add('at-top') } }, {threshold: 1}); observer.observe(topHook) }