/**
 * amis-ui v6.12.0-beta.0
 * Copyright 2018-2025 fex
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
var React = require('react');

var useOnScreen = function (ref) {
    var _a = tslib.__read(React.useState(false), 2), isIntersecting = _a[0], setIsIntersecting = _a[1];
    React.useEffect(function () {
        var observer = new IntersectionObserver(function (_a) {
            var _b = tslib.__read(_a, 1), entry = _b[0];
            setIsIntersecting(entry.isIntersecting);
        });
        if (ref.current) {
            observer.observe(ref.current);
        }
        return function () {
            if (ref.current) {
                observer.unobserve(ref.current);
            }
        };
    }, [ref]);
    return isIntersecting;
};

exports["default"] = useOnScreen;
