Observe how much of an element is visible with an IntersectionObserver.
This is custom React hooks, you need to follow the Basic Rules when you use it.
Scroll the page to change how much of the box is visible.
const useIntersection = <T extends HTMLElement = HTMLElement>(
options?: IntersectionObserverInit,
) => {
ref: (element: T | null) => void
entry: IntersectionObserverEntry | null
}