• Custom React hook that observes whether the specified element is "almost" within the visible area (viewport).

    This hook uses the useInViewport hook to determine when the element is nearly visible, based on a defined root margin. When the element enters this threshold, the provided callback is executed.

    Example

    const MyComponent = () => {
    const ref = useRef<HTMLDivElement>(null);

    const { isReady } = useLazyReady({
    ref,
    onIn: () => console.log('Element is almost in the viewport!'),
    });

    return <div ref={ref}>Observe me!</div>;
    };

    Parameters

    Returns {
        isReady: boolean;
    }

    • isReady: boolean