UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

12 lines (11 loc) 869 B
import { type RefObject } from "react"; import type { Callback } from "../../util/function.js"; import type { Nullish } from "../../util/null.js"; /** * Fires a callback when an element enters the visible scrolling area on the client. * - Checks that is the last element in its parent. * - Finds the closest parent above this that scrolls (e.g. `.page`, customisable with `selector` param), then fires the callbacks appropriately. */ export declare function useScrollIntersect<T extends HTMLElement>(onEnter?: Nullish<Callback>, onLeave?: Nullish<Callback>): RefObject<T | null>; /** Go through a list of `IntersectionObserverEntry` (from `IntersectionObserver`) and return the index of the one with the highest `intersectionRatio` */ export declare function getMostVisibleObserverEntry(entries: IntersectionObserverEntry[]): IntersectionObserverEntry | undefined;