use-intersection
Detects if given element is visible in the viewport or other element with IntersectionObserver
Source
Docs
PackageIcon
Usage
The use-intersection hook returns information about the intersection
of a given element with its scroll container or body element using the Intersection Observer API:
Obscured
API
The hook accepts IntersectionObserver's options as its only optional argument:
The hook returns a ref function that should be passed to the observed element, and the latest entry, as returned by the IntersectionObserver's callback.
See the Intersection Observer API documentation to learn everything about the options.
On the first render (as well as during SSR), or when no element is being observed, the entry is null.
Definition
Exported types
UseIntersectionReturnValue type is exported from @mantine/hooks package,
you can import it in your application: