@anoki/fse-marche-ui
Version:
FSE UI components library
66 lines (65 loc) • 1.82 kB
JavaScript
var p = function(e) {
return e.tagName === "TEXTAREA";
}, w = function(e, r) {
if (!(e instanceof Element))
return !1;
var o = window.getComputedStyle(e);
return (
// not-not-scrollable
o[r] !== "hidden" && // contains scroll inside self
!(o.overflowY === o.overflowX && !p(e) && o[r] === "visible")
);
}, y = function(e) {
return w(e, "overflowY");
}, H = function(e) {
return w(e, "overflowX");
}, R = function(e, r) {
var o = r.ownerDocument, t = r;
do {
typeof ShadowRoot < "u" && t instanceof ShadowRoot && (t = t.host);
var v = g(e, t);
if (v) {
var n = b(e, t), a = n[1], l = n[2];
if (a > l)
return !0;
}
t = t.parentNode;
} while (t && t !== o.body);
return !1;
}, B = function(e) {
var r = e.scrollTop, o = e.scrollHeight, t = e.clientHeight;
return [
r,
o,
t
];
}, V = function(e) {
var r = e.scrollLeft, o = e.scrollWidth, t = e.clientWidth;
return [
r,
o,
t
];
}, g = function(e, r) {
return e === "v" ? y(r) : H(r);
}, b = function(e, r) {
return e === "v" ? B(r) : V(r);
}, D = function(e, r) {
return e === "h" && r === "rtl" ? -1 : 1;
}, W = function(e, r, o, t, v) {
var n = D(e, window.getComputedStyle(r).direction), a = n * t, l = o.target, f = r.contains(l), i = !1, s = a > 0, d = 0, h = 0;
do {
var c = b(e, l), u = c[0], m = c[1], C = c[2], S = m - C - n * u;
(u || S) && g(e, l) && (d += S, h += u), l instanceof ShadowRoot ? l = l.host : l = l.parentNode;
} while (
// portaled content
!f && l !== document.body || // self content
f && (r.contains(l) || r === l)
);
return (s && Math.abs(d) < 1 || !s && Math.abs(h) < 1) && (i = !0), i;
};
export {
W as handleScroll,
R as locationCouldBeScrolled
};
//# sourceMappingURL=index.es295.js.map