import { type RefObject } from "react"; /** The measured window rect this module reasons about (x is irrelevant: the trigger * line is horizontal, so only the vertical edge and the degenerate-size check * matter). */ export interface InViewRect { /** Distance from the top of the window to the element's top edge. */ y: number; width: number; height: number; } /** * The one structural capability this module needs from a ref. Declared here rather * than imported so nothing DOM-shaped or Animated-shaped enters the type surface: * React Native's host instances and react-native-web's host nodes both satisfy it * (react-native-web attaches measureInWindow to the node in usePlatformMethods), * which is what lets one code path serve native and web. */ export interface InViewMeasurable { measureInWindow(callback: (x: number, y: number, width: number, height: number) => void): void; } /** * The pure in-view predicate: has an element with this window rect reached the * trigger line, given the window height and how far inside the bottom edge * (`insetDp`) the element must come before it counts? * * True means "reveal it". The test is on the element's TOP edge against a horizontal * trigger line at `windowHeight - inset`, which gives both cases the once-only * contract needs from a single comparison: * - scrolling up from below the fold: the top edge crosses the line, so the reveal * fires while the element is entering, not after it is fully in; * - a page opened already scrolled past the element (a deep link, a restored * scroll position): the top edge is negative, comfortably past the line, so the * content is already revealed instead of stranded invisible above the viewport. * The inset is clamped into the window, so even a nonsense inset only ever moves the * line to the top of the window rather than off it. * * Fail-open cases (see the file header) all return true. Exported for unit tests, * following the `entranceTranslation` precedent in ./entrance.tsx: the maths is the * load-bearing part and is testable with no renderer. */ export declare function isRectInView(rect: InViewRect | null | undefined, windowHeight: number, insetDp: number): boolean; /** * Whether the shared sampling timer is currently running. Kit-internal * introspection for the tests that assert the ticker starts on the first pending * element and stops when the last one resolves; components never read this. */ export declare function inViewTickerActive(): boolean; /** * Whether the element behind `ref` has reached the viewport, latched: it flips false * to true at most once and never back (see the file header on once-only). * * `insetDp` is how far inside the bottom edge of the window the element's top must * come before it counts, so a caller can require the element to be properly in view * rather than one pixel in. * * `enabled` is the caller's own reason to not observe at all. When false the hook * registers nothing, measures nothing, starts no timer, and reports `true`, which is * the fail-open answer: a caller that has decided not to watch (Reveal under Reduce * Motion) renders its final frame. It is a parameter rather than a Reduce Motion read * inside this hook so the accessibility POLICY stays with the component that owns the * animation, and this module stays a plain detector. * * Known imprecision, deliberate: the measurement is against the WINDOW, so an element * inside a nested scroll container that is clipped by that container but whose window * rect still falls inside the window counts as in view. It errs toward revealing * early, which is the direction this primitive is allowed to be wrong in, and the * alternative (walking ancestor clip rects) is a large amount of machinery for a * decorative entrance. */ export declare function useInView(ref: RefObject, insetDp: number, enabled?: boolean): boolean; //# sourceMappingURL=in-view.d.ts.map