export const stuck = (node: HTMLElement) => { const observer = new IntersectionObserver( ([entry]) => node.toggleAttribute( "data-stuck", entry.intersectionRatio < 1 && entry.boundingClientRect.top < 1 ), { rootMargin: "-1px 0px 0px 0px", threshold: 1 } ); observer.observe(node); return () => observer.disconnect(); };