UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

14 lines (13 loc) 674 B
/** * Hook that uses `IntersectionObserver` to trigger `onIntersect` callback when element is in viewport. * Callback is called only once by default (can be changed using the `once` parameter). * @returns a callback ref that needs to be set on the element you want to observe. * @private * @example * const onIntersection = React.useCallback(() => { * console.log('Element is in viewport!'); * }, []); * const ref = useIntersection(onIntersection); * return (<div ref={ref}>One of many elements</div>); */ export declare const useIntersection: (onIntersect: () => void, options?: IntersectionObserverInit, once?: boolean) => (node: HTMLElement | null) => void;