'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var root = require('./root');
var getComputedStyle = root.getComputedStyle;
var document = root.document;
exports = function(el) {
    var _ref =
            arguments.length > 1 && arguments[1] !== undefined
                ? arguments[1]
                : {},
        _ref$display = _ref.display,
        display = _ref$display === void 0 ? true : _ref$display,
        _ref$visibility = _ref.visibility,
        visibility = _ref$visibility === void 0 ? false : _ref$visibility,
        _ref$opacity = _ref.opacity,
        opacity = _ref$opacity === void 0 ? false : _ref$opacity,
        _ref$size = _ref.size,
        size = _ref$size === void 0 ? false : _ref$size,
        _ref$viewport = _ref.viewport,
        viewport = _ref$viewport === void 0 ? false : _ref$viewport,
        _ref$overflow = _ref.overflow,
        overflow = _ref$overflow === void 0 ? false : _ref$overflow;
    var computedStyle = getComputedStyle(el);
    if (display) {
        var tagName = el.tagName;
        if (
            tagName === 'BODY' ||
            tagName === 'HTML' ||
            computedStyle.position === 'fixed'
        ) {
            if (computedStyle.display === 'none') {
                return true;
            } else {
                var cur = el;
                while ((cur = cur.parentElement)) {
                    var _computedStyle = getComputedStyle(cur);
                    if (_computedStyle.display === 'none') {
                        return true;
                    }
                }
            }
        } else if (el.offsetParent === null) {
            return true;
        }
    }
    if (visibility && computedStyle.visibility === 'hidden') {
        return true;
    }
    if (opacity) {
        if (computedStyle.opacity === '0') {
            return true;
        } else {
            var _cur = el;
            while ((_cur = _cur.parentElement)) {
                var _computedStyle2 = getComputedStyle(_cur);
                if (_computedStyle2.opacity === '0') {
                    return true;
                }
            }
        }
    }
    var clientRect = el.getBoundingClientRect();
    if (size && (clientRect.width === 0 || clientRect.height === 0)) {
        return true;
    }
    if (viewport) {
        var containerRect = {
            top: 0,
            left: 0,
            right: document.documentElement.clientWidth,
            bottom: document.documentElement.clientHeight
        };
        return isOutside(clientRect, containerRect);
    }
    if (overflow) {
        var _cur2 = el;
        while ((_cur2 = _cur2.parentElement)) {
            var _computedStyle3 = getComputedStyle(_cur2);
            var _overflow = _computedStyle3.overflow;
            if (_overflow === 'scroll' || _overflow === 'hidden') {
                var curRect = _cur2.getBoundingClientRect();
                if (isOutside(clientRect, curRect)) return true;
            }
        }
    }
    return false;
};
function isOutside(clientRect, containerRect) {
    return (
        clientRect.right < containerRect.left ||
        clientRect.left > containerRect.right ||
        clientRect.bottom < containerRect.top ||
        clientRect.top > containerRect.bottom
    );
}
 
module.exports = exports;