| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- function J(e) {
- return typeof e == "object" && e != null && e.nodeType === 1;
- }
- function R(e, t) {
- return (!t || e !== "hidden") && e !== "visible" && e !== "clip";
- }
- function _(e, t) {
- if (e.clientHeight < e.scrollHeight || e.clientWidth < e.scrollWidth) {
- var o = getComputedStyle(e, null);
- return R(o.overflowY, t) || R(o.overflowX, t) || function(l) {
- var r = function(n) {
- if (!n.ownerDocument || !n.ownerDocument.defaultView) return null;
- try {
- return n.ownerDocument.defaultView.frameElement;
- } catch (f) {
- return null;
- }
- }(l);
- return !!r && (r.clientHeight < l.scrollHeight || r.clientWidth < l.scrollWidth);
- }(e);
- }
- return !1;
- }
- function D(e, t, o, l, r, n, f, d) {
- return n < e && f > t || n > e && f < t ? 0 : n <= e && d <= o || f >= t && d >= o ? n - e - l : f > t && d < o || n < e && d > o ? f - t + r : 0;
- }
- var B = function(e, t) {
- var o = window, l = t.scrollMode, r = t.block, n = t.inline, f = t.boundary, d = t.skipOverflowHiddenElements, te = typeof f == "function" ? f : function(ne) {
- return ne !== f;
- };
- if (!J(e)) throw new TypeError("Invalid target");
- for (var q, z, F = document.scrollingElement || document.documentElement, H = [], c = e; J(c) && te(c); ) {
- if ((c = (z = (q = c).parentElement) == null ? q.getRootNode().host || null : z) === F) {
- H.push(c);
- break;
- }
- c != null && c === document.body && _(c) && !_(document.documentElement) || c != null && _(c, d) && H.push(c);
- }
- for (var m = o.visualViewport ? o.visualViewport.width : innerWidth, v = o.visualViewport ? o.visualViewport.height : innerHeight, w = window.scrollX || pageXOffset, b = window.scrollY || pageYOffset, g = e.getBoundingClientRect(), W = g.height, y = g.width, O = g.top, Q = g.right, U = g.bottom, E = g.left, u = r === "start" || r === "nearest" ? O : r === "end" ? U : O + W / 2, s = n === "center" ? E + y / 2 : n === "end" ? Q : E, Z = [], $ = 0; $ < H.length; $++) {
- var i = H[$], p = i.getBoundingClientRect(), V = p.height, k = p.width, M = p.top, A = p.right, N = p.bottom, T = p.left;
- if (l === "if-needed" && O >= 0 && E >= 0 && U <= v && Q <= m && O >= M && U <= N && E >= T && Q <= A) return Z;
- var x = getComputedStyle(i), I = parseInt(x.borderLeftWidth, 10), S = parseInt(x.borderTopWidth, 10), j = parseInt(x.borderRightWidth, 10), L = parseInt(x.borderBottomWidth, 10), h = 0, a = 0, X = "offsetWidth" in i ? i.offsetWidth - i.clientWidth - I - j : 0, Y = "offsetHeight" in i ? i.offsetHeight - i.clientHeight - S - L : 0, K = "offsetWidth" in i ? i.offsetWidth === 0 ? 0 : k / i.offsetWidth : 0, P = "offsetHeight" in i ? i.offsetHeight === 0 ? 0 : V / i.offsetHeight : 0;
- if (F === i) h = r === "start" ? u : r === "end" ? u - v : r === "nearest" ? D(b, b + v, v, S, L, b + u, b + u + W, W) : u - v / 2, a = n === "start" ? s : n === "center" ? s - m / 2 : n === "end" ? s - m : D(w, w + m, m, I, j, w + s, w + s + y, y), h = Math.max(0, h + b), a = Math.max(0, a + w);
- else {
- h = r === "start" ? u - M - S : r === "end" ? u - N + L + Y : r === "nearest" ? D(M, N, V, S, L + Y, u, u + W, W) : u - (M + V / 2) + Y / 2, a = n === "start" ? s - T - I : n === "center" ? s - (T + k / 2) + X / 2 : n === "end" ? s - A + j + X : D(T, A, k, I, j + X, s, s + y, y);
- var C = i.scrollLeft, G = i.scrollTop;
- u += G - (h = Math.max(0, Math.min(G + h / P, i.scrollHeight - V / P + Y))), s += C - (a = Math.max(0, Math.min(C + a / K, i.scrollWidth - k / K + X)));
- }
- Z.push({ el: i, top: h, left: a });
- }
- return Z;
- };
- function ee(e) {
- return e === Object(e) && Object.keys(e).length !== 0;
- }
- function re(e, t) {
- t === void 0 && (t = "auto");
- var o = "scrollBehavior" in document.body.style;
- e.forEach(function(l) {
- var r = l.el, n = l.top, f = l.left;
- r.scroll && o ? r.scroll({
- top: n,
- left: f,
- behavior: t
- }) : (r.scrollTop = n, r.scrollLeft = f);
- });
- }
- function ie(e) {
- return e === !1 ? {
- block: "end",
- inline: "nearest"
- } : ee(e) ? e : {
- block: "start",
- inline: "nearest"
- };
- }
- function oe(e, t) {
- var o = e.isConnected || e.ownerDocument.documentElement.contains(e);
- if (ee(t) && typeof t.behavior == "function")
- return t.behavior(o ? B(e, t) : []);
- if (o) {
- var l = ie(t);
- return re(B(e, l), l.behavior);
- }
- }
- export {
- oe as s
- };
|