@modern-kit/react
Version:
34 lines (30 loc) • 964 B
JavaScript
;
var jsxRuntime = require('react/jsx-runtime');
var hooksUseIntersectionObserver = require('../../hooks/useIntersectionObserver/index.cjs');
require('react');
require('../../hooks/usePreservedCallback/index.cjs');
require('@modern-kit/utils');
const InfiniteScroll = ({
onScrollAction,
children,
root,
threshold,
enabled,
triggerPosition = "after",
rootMargin = "150px 0px"
}) => {
const { ref: observedRef } = hooksUseIntersectionObserver.useIntersectionObserver({
onIntersectStart: onScrollAction,
root,
threshold,
enabled,
rootMargin
});
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
triggerPosition === "before" && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: observedRef }),
children,
triggerPosition === "after" && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: observedRef })
] });
};
exports.InfiniteScroll = InfiniteScroll;
//# sourceMappingURL=index.cjs.map