/** * useNearViewport — module-level shared IntersectionObserver in hook form. * * Single IO instance per `rootMargin` value, shared across every component * that mounts the hook. Reduces overhead vs. one IO per component on * grid/list pages where many subscribers observe the viewport with the same * margin. Promoted from the inline singleton at * `multi-platform-hub/components/shared/video-bites-display.tsx:21-43`, * which is the only IO pattern in either repo today. * * Usage: * ```tsx * function MyCard() { * const { ref, isNear } = useNearViewport('500px'); * return
{isNear ? : }
; * } * ``` * * StrictMode safety: cleanup uses an identity check on the registered * callback so React's dev double-mount (mount → cleanup → re-mount) does * not drop the second mount's freshly-set subscription. The IO callback * also checks `subscribers.get(target)` before invoking so a fire that * races with unmount cannot crash on a torn-down component. * * The hook fires once — on first intersection it sets `isNear=true` and * unobserves the element. Callers that need re-observation should * unmount and remount (or fork the hook for two-way behavior). */ /** * Default near-viewport lookahead — the SSOT for "mount media on approach". * Shared by this hook's default AND the raw two-way IntersectionObservers in * `cards-strip.tsx` / `video-bites-strip.tsx` (which need mount+unmount, not * this hook's fire-once semantics, but must agree on the distance). */ export declare const NEAR_VIEWPORT_ROOT_MARGIN = "500px"; export interface UseNearViewportResult { /** Ref to attach to the element you want to gate on visibility. */ ref: (node: T | null) => void; /** Flips to `true` once the element enters within `rootMargin` of the viewport. Never flips back. */ isNear: boolean; } /** * @param rootMargin Margin around the viewport (CSS-style string). * '500px' = element starts mounting 500px before scroll-in. * '1000px' = a full viewport's worth of lookahead. * '0px' = strict on-screen detection. * @param threshold Fraction of the element that must be visible before firing * (0 = any pixel — the default; 0.5 = at least half on-screen). */ export declare function useNearViewport(rootMargin?: string, threshold?: number): UseNearViewportResult; //# sourceMappingURL=use-near-viewport.d.ts.map