UNPKG

@studio-lumio/hooks

Version:

a compilation of react hooks we use to make our magic

27 lines (26 loc) 1.37 kB
interface UseIntersectionObserverProps { root?: HTMLElement | null; rootMargin?: string; threshold?: number; once?: boolean; lazy?: boolean; callback?: (entry: IntersectionObserverEntry) => void; } type UseIntersectionObserverReturn = [ (element: HTMLElement | null) => void, IntersectionObserverEntry | (() => IntersectionObserverEntry | undefined) | any ]; /** * useIntersectionObserver - A React hook that observes element visibility using IntersectionObserver. * @param {object} props - Configuration options * @param {HTMLElement} props.root - The element that is used as the viewport for checking visibility. * @param {string} props.rootMargin - Margin around the root. * @param {number} props.threshold - Number from 0 to 1 indicating the percentage of the target's visibility. * @param {boolean} props.once - Whether to disconnect after first intersection. * @param {boolean} props.lazy - Whether to update state lazily. * @param {function} props.callback - Function to call when the intersection changes. * @param {array} deps - Dependency array for the effect. * @returns {array} [setElement, entry] */ export declare function useIntersectionObserver({ root, rootMargin, threshold, once, lazy, callback, }?: UseIntersectionObserverProps, deps?: any[]): UseIntersectionObserverReturn; export {};