UNPKG

@pdf-viewer/react

Version:

A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.

20 lines (19 loc) 489 B
import { useCallback as l, useEffect as f } from "react"; const v = (s, c, h = {}) => { const { distance: i = 10, loadFirst: t = !1 } = h, o = l( (u) => { if (!s) return; s.scrollHeight - s.clientHeight - s.scrollTop < i && c(); }, [c, s, i] ); f(() => { t && c(); }, [t]), f(() => (s == null || s.addEventListener("scroll", o), () => { s == null || s.removeEventListener("scroll", o); }), [o, s]); }; export { v as useInfiniteScroll };