/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

import { __read } from 'tslib';
import { useState, useEffect } from 'react';

var useOnScreen = function (ref) {
    var _a = __read(useState(false), 2), isIntersecting = _a[0], setIsIntersecting = _a[1];
    useEffect(function () {
        var observer = new IntersectionObserver(function (_a) {
            var _b = __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;
};

export { useOnScreen as default };
