"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useIntersectionObserver = void 0;
var react_1 = require("react");
function useIntersectionObserver(params) {
    var callback = params.callback, rootMargin = params.rootMargin, root = params.root, threshold = params.threshold;
    var ref = react_1.useRef(null);
    var observer = react_1.useMemo(function () {
        return new IntersectionObserver(function (entries) {
            callback({
                "entry": entries[0],
                observer: observer,
            });
        }, { rootMargin: rootMargin, root: root, threshold: threshold });
    }, []);
    react_1.useEffect(function () {
        if (!ref.current) {
            return;
        }
        observer.observe(ref.current);
    }, []);
    return { ref: ref };
}
exports.useIntersectionObserver = useIntersectionObserver;
//# sourceMappingURL=useIntersectionObserver.js.map