UNPKG

@modern-kit/react

Version:
32 lines (29 loc) 862 B
import { jsxs, Fragment, jsx } from 'react/jsx-runtime'; import { useIntersectionObserver } from '../../hooks/useIntersectionObserver/index.mjs'; import 'react'; import '../../hooks/usePreservedCallback/index.mjs'; import '@modern-kit/utils'; const InfiniteScroll = ({ onScrollAction, children, root, threshold, enabled, triggerPosition = "after", rootMargin = "150px 0px" }) => { const { ref: observedRef } = useIntersectionObserver({ onIntersectStart: onScrollAction, root, threshold, enabled, rootMargin }); return /* @__PURE__ */ jsxs(Fragment, { children: [ triggerPosition === "before" && /* @__PURE__ */ jsx("div", { ref: observedRef }), children, triggerPosition === "after" && /* @__PURE__ */ jsx("div", { ref: observedRef }) ] }); }; export { InfiniteScroll }; //# sourceMappingURL=index.mjs.map