useIntersectionObserver

Detects that a target element's visibility.

Demo

When viewing me...

Element is not in view

Scroll down

Usage

const const ref: Kaioken.MutableRefObject<HTMLElement | null>ref = useRef<HTMLElement | null>(initialValue: HTMLElement | null): Kaioken.MutableRefObject<HTMLElement | null> (+2 overloads)useRef<HTMLElement | null>(null)
const 
const controls: {
    isSupported: boolean;
    start: () => void;
    stop: () => void;
}
controls
=
function useIntersectionObserver(ref: Kaioken.MutableRefObject<Element | null>, callback: IntersectionObserverCallback, options?: IntersectionObserverInit | undefined): {
    isSupported: boolean;
    start: () => void;
    stop: () => void;
}
useIntersectionObserver
(const ref: Kaioken.MutableRefObject<HTMLElement | null>ref, (intersections: IntersectionObserverEntry[]intersections) => {
// code here })