Skip to content
aq-ui
Back to HooksHook

Use Intersection Observer

Open-code aq-ui React hook for Use Intersection Observer.

Installation

pnpm dlx aq-ui@alpha add use-intersection-observer

API reference

Client module

Import the parts you need, then jump to an export for its contract.

View full source

Quick start

"use client"

import { useIntersectionObserver } from "@/hooks/use-intersection-observer"

IntersectionObserverResult

interfaceSource L15

Type contract for IntersectionObserverResult.

interface IntersectionObserverResult

Members

NameType
entryIntersectionObserverEntry | null
isIntersectingboolean
supportedboolean

useIntersectionObserver

functionSource L21

Open-code aq-ui React hook for Use Intersection Observer.

function useIntersectionObserver<T extends Element>(target: Target<T>, { root, rootMargin, threshold, enabled = true, freezeOnceVisible = false, onChange, }: UseIntersectionObserverOptions = {}): IntersectionObserverResult
Returns
IntersectionObserverResult

Parameters

NameTypeDefault
targetTarget<T>—
options?UseIntersectionObserverOptions{}

UseIntersectionObserverOptions

interfaceSource L9

Type contract for UseIntersectionObserverOptions.

interface UseIntersectionObserverOptions extends IntersectionObserverInit

Members

NameTypeDefault
enabled?booleantrue
freezeOnceVisible?booleanfalse
onChange?(entry: IntersectionObserverEntry) => void—

Registry dependencies

hook-observer-pools, hook-target, use-stable-callback

Files

  • hooks/use-intersection-observer.ts

Source