useIntersectionObserver

    API

    import useIntersectionObserver from '@restart/hooks/useIntersectionObserver'
    • useIntersectionObserver<TElement>(element: TElement | null | undefined, options?: IntersectionObserverInit) => IntersectionObserverEntry[]

      Setup an IntersectionObserver on a DOM Element that returns it's entries as they arrive.

      Parameters

      • elementTElement | null | undefined

        The DOM element to observe

      • options?IntersectionObserverInit

      Return Value IntersectionObserverEntry[]

    • useIntersectionObserver<TElement>(element: TElement | null | undefined, callback: IntersectionObserverCallback, options?: IntersectionObserverInit) => void

      Setup an IntersectionObserver on a DOM Element. This overload does not trigger component updates when receiving new entries. This allows for finer grained performance optimizations by the consumer.

      Parameters

      • elementTElement | null | undefined

        The DOM element to observe

      • callbackIntersectionObserverCallback

        A listener for intersection updates.

      • options?IntersectionObserverInit

      Return Value void