mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-12 16:42:30 +03:00
improve code
This commit is contained in:
+142
-134
@@ -1162,13 +1162,17 @@ var OverlayScrollbars = function(r) {
|
||||
y: 0 === d.y
|
||||
};
|
||||
var p = {
|
||||
host: null,
|
||||
padding: !g,
|
||||
viewport: function viewport(r) {
|
||||
return g && r === r.ownerDocument.body && r;
|
||||
elements: {
|
||||
host: null,
|
||||
padding: !g,
|
||||
viewport: function viewport(r) {
|
||||
return g && r === r.ownerDocument.body && r;
|
||||
},
|
||||
content: false
|
||||
},
|
||||
scrollbars: {
|
||||
slot: true
|
||||
},
|
||||
content: false,
|
||||
scrollbarsSlot: true,
|
||||
cancel: {
|
||||
nativeScrollbarsOverlaid: false,
|
||||
body: null
|
||||
@@ -1281,111 +1285,113 @@ var OverlayScrollbars = function(r) {
|
||||
var n = a.U, e = a.T;
|
||||
var t = Ia()[cn];
|
||||
var i = t && t.L;
|
||||
var v = n(), o = v.host, u = v.viewport, f = v.padding, l = v.content;
|
||||
var c = b(r);
|
||||
var s = c ? {} : r;
|
||||
var d = s.host, g = s.padding, h = s.viewport, p = s.content;
|
||||
var w = c ? r : s.target;
|
||||
var S = j(w, "textarea");
|
||||
var C = w.ownerDocument;
|
||||
var x = w === C.body;
|
||||
var A = C.defaultView;
|
||||
var P = yn.bind(0, [ w ]);
|
||||
var z = Sn.bind(0, [ w ]);
|
||||
var M = P(Hn, u, h);
|
||||
var R = M === w;
|
||||
var I = R && x;
|
||||
var V = !R && A.top === A && C.activeElement === w;
|
||||
var k = {
|
||||
$: w,
|
||||
J: S ? P(Hn, o, d) : w,
|
||||
K: M,
|
||||
rr: !R && z(Hn, f, g),
|
||||
ar: !R && z(Hn, l, p),
|
||||
nr: !R && !e && i && i(a),
|
||||
er: I ? C.documentElement : M,
|
||||
tr: I ? C : M,
|
||||
ir: A,
|
||||
vr: C,
|
||||
ur: S,
|
||||
Z: x,
|
||||
lr: c,
|
||||
cr: R,
|
||||
var v = n(), o = v.elements;
|
||||
var u = o.host, f = o.viewport, l = o.padding, c = o.content;
|
||||
var s = b(r);
|
||||
var d = s ? {} : r;
|
||||
var g = d.elements;
|
||||
var h = g || {}, p = h.host, w = h.padding, S = h.viewport, C = h.content;
|
||||
var x = s ? r : d.target;
|
||||
var A = j(x, "textarea");
|
||||
var P = x.ownerDocument;
|
||||
var z = x === P.body;
|
||||
var M = P.defaultView;
|
||||
var R = yn.bind(0, [ x ]);
|
||||
var I = Sn.bind(0, [ x ]);
|
||||
var V = R(Hn, f, S);
|
||||
var k = V === x;
|
||||
var q = k && z;
|
||||
var U = !k && M.top === M && P.activeElement === x;
|
||||
var N = {
|
||||
$: x,
|
||||
J: A ? R(Hn, u, p) : x,
|
||||
K: V,
|
||||
rr: !k && I(Hn, l, w),
|
||||
ar: !k && I(Hn, c, C),
|
||||
nr: !k && !e && i && i(a),
|
||||
er: q ? P.documentElement : V,
|
||||
tr: q ? P : V,
|
||||
ir: M,
|
||||
vr: P,
|
||||
ur: A,
|
||||
Z: z,
|
||||
lr: s,
|
||||
cr: k,
|
||||
sr: function _viewportHasClass(r, a) {
|
||||
return R ? H(M, na, a) : gr(M, r);
|
||||
return k ? H(V, na, a) : gr(V, r);
|
||||
},
|
||||
dr: function _viewportAddRemoveClass(r, a, n) {
|
||||
return R ? T(M, na, a, n) : (n ? pr : hr)(M, r);
|
||||
return k ? T(V, na, a, n) : (n ? pr : hr)(V, r);
|
||||
}
|
||||
};
|
||||
var q = E(k).reduce((function(r, a) {
|
||||
var n = k[a];
|
||||
var Z = E(N).reduce((function(r, a) {
|
||||
var n = N[a];
|
||||
return y(r, n && !F(n) ? n : false);
|
||||
}), []);
|
||||
var U = function elementIsGenerated(r) {
|
||||
return r ? m(q, r) > -1 : null;
|
||||
var $ = function elementIsGenerated(r) {
|
||||
return r ? m(Z, r) > -1 : null;
|
||||
};
|
||||
var N = k.$, Z = k.J, $ = k.rr, J = k.K, K = k.ar, Q = k.nr;
|
||||
var rr = [];
|
||||
var ar = S && U(Z);
|
||||
var nr = S ? N : B([ K, J, $, Z, N ].find((function(r) {
|
||||
return false === U(r);
|
||||
var J = N.$, K = N.J, Q = N.rr, rr = N.K, ar = N.ar, nr = N.nr;
|
||||
var er = [];
|
||||
var tr = A && $(K);
|
||||
var ir = A ? J : B([ ar, rr, Q, K, J ].find((function(r) {
|
||||
return false === $(r);
|
||||
})));
|
||||
var er = K || J;
|
||||
var tr = function appendElements() {
|
||||
var r = Mn(Z, R ? "viewport" : "host");
|
||||
var a = pr($, ua);
|
||||
var n = pr(J, !R && fa);
|
||||
var t = pr(K, ca);
|
||||
var i = x ? pr(F(w), sa) : Sr;
|
||||
if (ar) {
|
||||
G(N, Z);
|
||||
y(rr, (function() {
|
||||
G(Z, N);
|
||||
X(Z);
|
||||
var vr = ar || rr;
|
||||
var or = function appendElements() {
|
||||
var r = Mn(K, k ? "viewport" : "host");
|
||||
var a = pr(Q, ua);
|
||||
var n = pr(rr, !k && fa);
|
||||
var t = pr(ar, ca);
|
||||
var i = z ? pr(F(x), sa) : Sr;
|
||||
if (tr) {
|
||||
G(J, K);
|
||||
y(er, (function() {
|
||||
G(K, J);
|
||||
X(K);
|
||||
}));
|
||||
}
|
||||
Y(er, nr);
|
||||
Y(Z, $);
|
||||
Y($ || Z, !R && J);
|
||||
Y(J, K);
|
||||
y(rr, (function() {
|
||||
Y(vr, ir);
|
||||
Y(K, Q);
|
||||
Y(Q || K, !k && rr);
|
||||
Y(rr, ar);
|
||||
y(er, (function() {
|
||||
i();
|
||||
r();
|
||||
D(J, ea);
|
||||
D(J, ta);
|
||||
if (U(K)) {
|
||||
Dn(K);
|
||||
D(rr, ea);
|
||||
D(rr, ta);
|
||||
if ($(ar)) {
|
||||
Dn(ar);
|
||||
}
|
||||
if (U(J)) {
|
||||
Dn(J);
|
||||
if ($(rr)) {
|
||||
Dn(rr);
|
||||
}
|
||||
if (U($)) {
|
||||
Dn($);
|
||||
if ($(Q)) {
|
||||
Dn(Q);
|
||||
}
|
||||
a();
|
||||
n();
|
||||
t();
|
||||
}));
|
||||
if (e && !R) {
|
||||
y(rr, hr.bind(0, J, sa));
|
||||
if (e && !k) {
|
||||
y(er, hr.bind(0, rr, sa));
|
||||
}
|
||||
if (Q) {
|
||||
W(J, Q);
|
||||
y(rr, X.bind(0, Q));
|
||||
if (nr) {
|
||||
W(rr, nr);
|
||||
y(er, X.bind(0, nr));
|
||||
}
|
||||
if (V) {
|
||||
var v = L(J, Tn);
|
||||
L(J, Tn, "-1");
|
||||
J.focus();
|
||||
var o = Ur(C, "pointerdown keydown", (function() {
|
||||
v ? L(J, Tn, v) : D(J, Tn);
|
||||
if (U) {
|
||||
var v = L(rr, Tn);
|
||||
L(rr, Tn, "-1");
|
||||
rr.focus();
|
||||
var o = Ur(P, "pointerdown keydown", (function() {
|
||||
v ? L(rr, Tn, v) : D(rr, Tn);
|
||||
o();
|
||||
}));
|
||||
}
|
||||
nr = 0;
|
||||
ir = 0;
|
||||
};
|
||||
return [ k, tr, O.bind(0, rr) ];
|
||||
return [ N, or, O.bind(0, er) ];
|
||||
};
|
||||
var In = function createTrinsicUpdateSegment(r, a) {
|
||||
var n = r.ar;
|
||||
@@ -2410,105 +2416,107 @@ var OverlayScrollbars = function(r) {
|
||||
};
|
||||
var Ee = function createScrollbarsSetupElements(r, a, n) {
|
||||
var e = wn(), t = e.U;
|
||||
var i = t(), v = i.scrollbarsSlot;
|
||||
var o = a.vr, u = a.$, f = a.J, l = a.K, s = a.lr, d = a.er;
|
||||
var g = s ? {} : r, h = g.scrollbarsSlot;
|
||||
var p = Sn([ u, f, l ], (function() {
|
||||
return f;
|
||||
}), v, h);
|
||||
var b = function scrollbarStructureAddRemoveClass(r, a, n) {
|
||||
var i = t(), v = i.scrollbars;
|
||||
var o = v.slot;
|
||||
var u = a.vr, f = a.$, l = a.J, s = a.K, d = a.lr, g = a.er;
|
||||
var h = d ? {} : r, p = h.scrollbars;
|
||||
var b = p || {}, w = b.slot;
|
||||
var m = Sn([ f, l, s ], (function() {
|
||||
return l;
|
||||
}), o, w);
|
||||
var S = function scrollbarStructureAddRemoveClass(r, a, n) {
|
||||
var e = n ? pr : hr;
|
||||
each(r, (function(r) {
|
||||
e(r.Wr, a);
|
||||
}));
|
||||
};
|
||||
var w = function scrollbarsHandleStyle(r, a) {
|
||||
var x = function scrollbarsHandleStyle(r, a) {
|
||||
each(r, (function(r) {
|
||||
var n = a(r), e = n[0], t = n[1];
|
||||
style(e, t);
|
||||
}));
|
||||
};
|
||||
var m = function scrollbarStructureRefreshHandleLength(r, a, n) {
|
||||
w(r, (function(r) {
|
||||
var E = function scrollbarStructureRefreshHandleLength(r, a, n) {
|
||||
x(r, (function(r) {
|
||||
var e;
|
||||
var t = r.Nr, i = r.Yr;
|
||||
return [ t, (e = {}, e[n ? "width" : "height"] = (100 * Oe(t, i, n, a)).toFixed(3) + "%",
|
||||
e) ];
|
||||
}));
|
||||
};
|
||||
var S = function scrollbarStructureRefreshHandleOffset(r, a, n) {
|
||||
var A = function scrollbarStructureRefreshHandleOffset(r, a, n) {
|
||||
var e = n ? "X" : "Y";
|
||||
w(r, (function(r) {
|
||||
x(r, (function(r) {
|
||||
var t = r.Nr, i = r.Yr, v = r.Wr;
|
||||
var o = xe(t, i, d, a, zr(v), n);
|
||||
var o = xe(t, i, g, a, zr(v), n);
|
||||
var u = o === o;
|
||||
return [ t, {
|
||||
transform: u ? "translate" + e + "(" + (100 * o).toFixed(3) + "%)" : ""
|
||||
} ];
|
||||
}));
|
||||
};
|
||||
var x = [];
|
||||
var E = [];
|
||||
var A = [];
|
||||
var P = function scrollbarsAddRemoveClass(r, a, n) {
|
||||
var P = [];
|
||||
var z = [];
|
||||
var L = [];
|
||||
var T = function scrollbarsAddRemoveClass(r, a, n) {
|
||||
var e = c(n);
|
||||
var t = e ? n : true;
|
||||
var i = e ? !n : true;
|
||||
t && b(E, r, a);
|
||||
i && b(A, r, a);
|
||||
t && S(z, r, a);
|
||||
i && S(L, r, a);
|
||||
};
|
||||
var z = function refreshScrollbarsHandleLength(r) {
|
||||
m(E, r, true);
|
||||
m(A, r);
|
||||
var H = function refreshScrollbarsHandleLength(r) {
|
||||
E(z, r, true);
|
||||
E(L, r);
|
||||
};
|
||||
var L = function refreshScrollbarsHandleOffset(r) {
|
||||
S(E, r, true);
|
||||
S(A, r);
|
||||
var D = function refreshScrollbarsHandleOffset(r) {
|
||||
A(z, r, true);
|
||||
A(L, r);
|
||||
};
|
||||
var T = function generateScrollbarDOM(r) {
|
||||
var M = function generateScrollbarDOM(r) {
|
||||
var a = r ? Ca : Oa;
|
||||
var e = r ? E : A;
|
||||
var e = r ? z : L;
|
||||
var t = C(e) ? za : "";
|
||||
var i = Z(ya + " " + a + " " + t);
|
||||
var v = Z(xa);
|
||||
var u = Z(Ea);
|
||||
var o = Z(Ea);
|
||||
var f = {
|
||||
Wr: i,
|
||||
Yr: v,
|
||||
Nr: u
|
||||
Nr: o
|
||||
};
|
||||
Y(i, v);
|
||||
Y(v, u);
|
||||
Y(v, o);
|
||||
y(e, f);
|
||||
y(x, [ X.bind(0, i), n(f, P, o, d, r) ]);
|
||||
y(P, [ X.bind(0, i), n(f, T, u, g, r) ]);
|
||||
return f;
|
||||
};
|
||||
var H = T.bind(0, true);
|
||||
var D = T.bind(0, false);
|
||||
var M = function appendElements() {
|
||||
Y(p, E[0].Wr);
|
||||
Y(p, A[0].Wr);
|
||||
var R = M.bind(0, true);
|
||||
var I = M.bind(0, false);
|
||||
var V = function appendElements() {
|
||||
Y(m, z[0].Wr);
|
||||
Y(m, L[0].Wr);
|
||||
lr((function() {
|
||||
P(za);
|
||||
T(za);
|
||||
}), 300);
|
||||
};
|
||||
H();
|
||||
D();
|
||||
R();
|
||||
I();
|
||||
return [ {
|
||||
Gr: z,
|
||||
Xr: L,
|
||||
Zr: P,
|
||||
Gr: H,
|
||||
Xr: D,
|
||||
Zr: T,
|
||||
$r: {
|
||||
Jr: E,
|
||||
Kr: H,
|
||||
Qr: w.bind(0, E)
|
||||
Jr: z,
|
||||
Kr: R,
|
||||
Qr: x.bind(0, z)
|
||||
},
|
||||
ra: {
|
||||
Jr: A,
|
||||
Kr: D,
|
||||
Qr: w.bind(0, A)
|
||||
Jr: L,
|
||||
Kr: I,
|
||||
Qr: x.bind(0, L)
|
||||
}
|
||||
}, M, O.bind(0, x) ];
|
||||
}, V, O.bind(0, P) ];
|
||||
};
|
||||
var Ae = function createSelfCancelTimeout(r) {
|
||||
var a;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+119
-111
@@ -970,11 +970,15 @@ const OverlayScrollbars = function(t) {
|
||||
y: 0 === i.y
|
||||
};
|
||||
const d = {
|
||||
host: null,
|
||||
padding: !a,
|
||||
viewport: t => a && t === t.ownerDocument.body && t,
|
||||
content: false,
|
||||
scrollbarsSlot: true,
|
||||
elements: {
|
||||
host: null,
|
||||
padding: !a,
|
||||
viewport: t => a && t === t.ownerDocument.body && t,
|
||||
content: false
|
||||
},
|
||||
scrollbars: {
|
||||
slot: true
|
||||
},
|
||||
cancel: {
|
||||
nativeScrollbarsOverlaid: false,
|
||||
body: null
|
||||
@@ -1071,103 +1075,105 @@ const OverlayScrollbars = function(t) {
|
||||
const {Y: o, T: s} = n;
|
||||
const e = getPlugins()[mt];
|
||||
const c = e && e.A;
|
||||
const {host: r, viewport: l, padding: i, content: a} = o();
|
||||
const u = isHTMLElement(t);
|
||||
const d = u ? {} : t;
|
||||
const {host: f, padding: _, viewport: h, content: g} = d;
|
||||
const v = u ? t : d.target;
|
||||
const w = is(v, "textarea");
|
||||
const p = v.ownerDocument;
|
||||
const b = v === p.body;
|
||||
const y = p.defaultView;
|
||||
const m = staticInitializationElement.bind(0, [ v ]);
|
||||
const S = dynamicInitializationElement.bind(0, [ v ]);
|
||||
const x = m(Ot, l, h);
|
||||
const $ = x === v;
|
||||
const C = $ && b;
|
||||
const T = !$ && y.top === y && p.activeElement === v;
|
||||
const z = {
|
||||
X: v,
|
||||
J: w ? m(Ot, r, f) : v,
|
||||
K: x,
|
||||
Z: !$ && S(Ot, i, _),
|
||||
tt: !$ && S(Ot, a, g),
|
||||
nt: !$ && !s && c && c(n),
|
||||
ot: C ? p.documentElement : x,
|
||||
st: C ? p : x,
|
||||
et: y,
|
||||
ct: p,
|
||||
rt: w,
|
||||
W: b,
|
||||
lt: u,
|
||||
it: $,
|
||||
ut: (t, n) => $ ? hasAttrClass(x, O, n) : hasClass(x, t),
|
||||
dt: (t, n, o) => $ ? attrClass(x, O, n, o) : (o ? addClass : removeClass)(x, t)
|
||||
const {elements: r} = o();
|
||||
const {host: l, viewport: i, padding: a, content: u} = r;
|
||||
const d = isHTMLElement(t);
|
||||
const f = d ? {} : t;
|
||||
const {elements: _} = f;
|
||||
const {host: h, padding: g, viewport: v, content: w} = _ || {};
|
||||
const p = d ? t : f.target;
|
||||
const b = is(p, "textarea");
|
||||
const y = p.ownerDocument;
|
||||
const m = p === y.body;
|
||||
const S = y.defaultView;
|
||||
const x = staticInitializationElement.bind(0, [ p ]);
|
||||
const $ = dynamicInitializationElement.bind(0, [ p ]);
|
||||
const C = x(Ot, i, v);
|
||||
const T = C === p;
|
||||
const z = T && m;
|
||||
const I = !T && S.top === S && y.activeElement === p;
|
||||
const P = {
|
||||
X: p,
|
||||
J: b ? x(Ot, l, h) : p,
|
||||
K: C,
|
||||
Z: !T && $(Ot, a, g),
|
||||
tt: !T && $(Ot, u, w),
|
||||
nt: !T && !s && c && c(n),
|
||||
ot: z ? y.documentElement : C,
|
||||
st: z ? y : C,
|
||||
et: S,
|
||||
ct: y,
|
||||
rt: b,
|
||||
W: m,
|
||||
lt: d,
|
||||
it: T,
|
||||
ut: (t, n) => T ? hasAttrClass(C, O, n) : hasClass(C, t),
|
||||
dt: (t, n, o) => T ? attrClass(C, O, n, o) : (o ? addClass : removeClass)(C, t)
|
||||
};
|
||||
const I = keys(z).reduce(((t, n) => {
|
||||
const o = z[n];
|
||||
const R = keys(P).reduce(((t, n) => {
|
||||
const o = P[n];
|
||||
return push(t, o && !parent(o) ? o : false);
|
||||
}), []);
|
||||
const elementIsGenerated = t => t ? indexOf(I, t) > -1 : null;
|
||||
const {X: P, J: R, Z: k, K: B, tt: V, nt: j} = z;
|
||||
const Y = [];
|
||||
const q = w && elementIsGenerated(R);
|
||||
let F = w ? P : contents([ V, B, k, R, P ].find((t => false === elementIsGenerated(t))));
|
||||
const G = V || B;
|
||||
const elementIsGenerated = t => t ? indexOf(R, t) > -1 : null;
|
||||
const {X: k, J: B, Z: V, K: j, tt: Y, nt: q} = P;
|
||||
const F = [];
|
||||
const G = b && elementIsGenerated(B);
|
||||
let N = b ? k : contents([ Y, j, V, B, k ].find((t => false === elementIsGenerated(t))));
|
||||
const U = Y || j;
|
||||
const appendElements = () => {
|
||||
const t = addDataAttrHost(R, $ ? "viewport" : "host");
|
||||
const n = addClass(k, L);
|
||||
const o = addClass(B, !$ && H);
|
||||
const e = addClass(V, D);
|
||||
const c = b ? addClass(parent(v), M) : noop;
|
||||
if (q) {
|
||||
insertAfter(P, R);
|
||||
push(Y, (() => {
|
||||
insertAfter(R, P);
|
||||
removeElements(R);
|
||||
const t = addDataAttrHost(B, T ? "viewport" : "host");
|
||||
const n = addClass(V, L);
|
||||
const o = addClass(j, !T && H);
|
||||
const e = addClass(Y, D);
|
||||
const c = m ? addClass(parent(p), M) : noop;
|
||||
if (G) {
|
||||
insertAfter(k, B);
|
||||
push(F, (() => {
|
||||
insertAfter(B, k);
|
||||
removeElements(B);
|
||||
}));
|
||||
}
|
||||
appendChildren(G, F);
|
||||
appendChildren(R, k);
|
||||
appendChildren(k || R, !$ && B);
|
||||
appendChildren(U, N);
|
||||
appendChildren(B, V);
|
||||
push(Y, (() => {
|
||||
appendChildren(V || B, !T && j);
|
||||
appendChildren(j, Y);
|
||||
push(F, (() => {
|
||||
c();
|
||||
t();
|
||||
removeAttr(B, E);
|
||||
removeAttr(B, A);
|
||||
removeAttr(j, E);
|
||||
removeAttr(j, A);
|
||||
if (elementIsGenerated(Y)) {
|
||||
unwrap(Y);
|
||||
}
|
||||
if (elementIsGenerated(j)) {
|
||||
unwrap(j);
|
||||
}
|
||||
if (elementIsGenerated(V)) {
|
||||
unwrap(V);
|
||||
}
|
||||
if (elementIsGenerated(B)) {
|
||||
unwrap(B);
|
||||
}
|
||||
if (elementIsGenerated(k)) {
|
||||
unwrap(k);
|
||||
}
|
||||
n();
|
||||
o();
|
||||
e();
|
||||
}));
|
||||
if (s && !$) {
|
||||
push(Y, removeClass.bind(0, B, M));
|
||||
if (s && !T) {
|
||||
push(F, removeClass.bind(0, j, M));
|
||||
}
|
||||
if (j) {
|
||||
insertBefore(B, j);
|
||||
push(Y, removeElements.bind(0, j));
|
||||
if (q) {
|
||||
insertBefore(j, q);
|
||||
push(F, removeElements.bind(0, q));
|
||||
}
|
||||
if (T) {
|
||||
const t = attr(B, Ct);
|
||||
attr(B, Ct, "-1");
|
||||
B.focus();
|
||||
const n = on(p, "pointerdown keydown", (() => {
|
||||
t ? attr(B, Ct, t) : removeAttr(B, Ct);
|
||||
if (I) {
|
||||
const t = attr(j, Ct);
|
||||
attr(j, Ct, "-1");
|
||||
j.focus();
|
||||
const n = on(y, "pointerdown keydown", (() => {
|
||||
t ? attr(j, Ct, t) : removeAttr(j, Ct);
|
||||
n();
|
||||
}));
|
||||
}
|
||||
F = 0;
|
||||
N = 0;
|
||||
};
|
||||
return [ z, appendElements, runEachAndClear.bind(0, Y) ];
|
||||
return [ P, appendElements, runEachAndClear.bind(0, F) ];
|
||||
};
|
||||
const createTrinsicUpdateSegment = (t, n) => {
|
||||
const {tt: o} = t;
|
||||
@@ -2149,10 +2155,12 @@ const OverlayScrollbars = function(t) {
|
||||
};
|
||||
const createScrollbarsSetupElements = (t, n, o) => {
|
||||
const {Y: s} = getEnvironment();
|
||||
const {scrollbarsSlot: e} = s();
|
||||
const {ct: c, X: r, J: l, K: i, lt: a, ot: u} = n;
|
||||
const {scrollbarsSlot: d} = a ? {} : t;
|
||||
const f = dynamicInitializationElement([ r, l, i ], (() => l), e, d);
|
||||
const {scrollbars: e} = s();
|
||||
const {slot: c} = e;
|
||||
const {ct: r, X: l, J: i, K: a, lt: u, ot: d} = n;
|
||||
const {scrollbars: f} = u ? {} : t;
|
||||
const {slot: _} = f || {};
|
||||
const g = dynamicInitializationElement([ l, i, a ], (() => i), c, _);
|
||||
const scrollbarStructureAddRemoveClass = (t, n, o) => {
|
||||
const s = o ? addClass : removeClass;
|
||||
each(t, (t => {
|
||||
@@ -2177,75 +2185,75 @@ const OverlayScrollbars = function(t) {
|
||||
const s = o ? "X" : "Y";
|
||||
scrollbarsHandleStyle(t, (t => {
|
||||
const {qt: e, Ft: c, Gt: r} = t;
|
||||
const l = getScrollbarHandleOffsetRatio(e, c, u, n, directionIsRTL(r), o);
|
||||
const l = getScrollbarHandleOffsetRatio(e, c, d, n, directionIsRTL(r), o);
|
||||
const i = l === l;
|
||||
return [ e, {
|
||||
transform: i ? `translate${s}(${(100 * l).toFixed(3)}%)` : ""
|
||||
} ];
|
||||
}));
|
||||
};
|
||||
const _ = [];
|
||||
const g = [];
|
||||
const v = [];
|
||||
const w = [];
|
||||
const p = [];
|
||||
const scrollbarsAddRemoveClass = (t, n, o) => {
|
||||
const s = isBoolean(o);
|
||||
const e = s ? o : true;
|
||||
const c = s ? !o : true;
|
||||
e && scrollbarStructureAddRemoveClass(g, t, n);
|
||||
c && scrollbarStructureAddRemoveClass(v, t, n);
|
||||
e && scrollbarStructureAddRemoveClass(w, t, n);
|
||||
c && scrollbarStructureAddRemoveClass(p, t, n);
|
||||
};
|
||||
const refreshScrollbarsHandleLength = t => {
|
||||
scrollbarStructureRefreshHandleLength(g, t, true);
|
||||
scrollbarStructureRefreshHandleLength(v, t);
|
||||
scrollbarStructureRefreshHandleLength(w, t, true);
|
||||
scrollbarStructureRefreshHandleLength(p, t);
|
||||
};
|
||||
const refreshScrollbarsHandleOffset = t => {
|
||||
scrollbarStructureRefreshHandleOffset(g, t, true);
|
||||
scrollbarStructureRefreshHandleOffset(v, t);
|
||||
scrollbarStructureRefreshHandleOffset(w, t, true);
|
||||
scrollbarStructureRefreshHandleOffset(p, t);
|
||||
};
|
||||
const generateScrollbarDOM = t => {
|
||||
const n = t ? U : W;
|
||||
const s = t ? g : v;
|
||||
const s = t ? w : p;
|
||||
const e = isEmptyArray(s) ? Q : "";
|
||||
const r = createDiv(`${G} ${n} ${e}`);
|
||||
const c = createDiv(`${G} ${n} ${e}`);
|
||||
const l = createDiv(X);
|
||||
const i = createDiv(J);
|
||||
const a = {
|
||||
Gt: r,
|
||||
Gt: c,
|
||||
Ft: l,
|
||||
qt: i
|
||||
};
|
||||
appendChildren(r, l);
|
||||
appendChildren(c, l);
|
||||
appendChildren(l, i);
|
||||
push(s, a);
|
||||
push(_, [ removeElements.bind(0, r), o(a, scrollbarsAddRemoveClass, c, u, t) ]);
|
||||
push(v, [ removeElements.bind(0, c), o(a, scrollbarsAddRemoveClass, r, d, t) ]);
|
||||
return a;
|
||||
};
|
||||
const w = generateScrollbarDOM.bind(0, true);
|
||||
const p = generateScrollbarDOM.bind(0, false);
|
||||
const b = generateScrollbarDOM.bind(0, true);
|
||||
const y = generateScrollbarDOM.bind(0, false);
|
||||
const appendElements = () => {
|
||||
appendChildren(f, g[0].Gt);
|
||||
appendChildren(f, v[0].Gt);
|
||||
appendChildren(g, w[0].Gt);
|
||||
appendChildren(g, p[0].Gt);
|
||||
h((() => {
|
||||
scrollbarsAddRemoveClass(Q);
|
||||
}), 300);
|
||||
};
|
||||
w();
|
||||
p();
|
||||
b();
|
||||
y();
|
||||
return [ {
|
||||
Nt: refreshScrollbarsHandleLength,
|
||||
Ut: refreshScrollbarsHandleOffset,
|
||||
Wt: scrollbarsAddRemoveClass,
|
||||
Xt: {
|
||||
Jt: g,
|
||||
Kt: w,
|
||||
Zt: scrollbarsHandleStyle.bind(0, g)
|
||||
Jt: w,
|
||||
Kt: b,
|
||||
Zt: scrollbarsHandleStyle.bind(0, w)
|
||||
},
|
||||
Qt: {
|
||||
Jt: v,
|
||||
Kt: p,
|
||||
Zt: scrollbarsHandleStyle.bind(0, v)
|
||||
Jt: p,
|
||||
Kt: y,
|
||||
Zt: scrollbarsHandleStyle.bind(0, p)
|
||||
}
|
||||
}, appendElements, runEachAndClear.bind(0, _) ];
|
||||
}, appendElements, runEachAndClear.bind(0, v) ];
|
||||
};
|
||||
const createSelfCancelTimeout = t => {
|
||||
let n;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+344
-336
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+119
-111
@@ -1136,11 +1136,15 @@ const createEnvironment = () => {
|
||||
y: 0 === l.y
|
||||
};
|
||||
const d = {
|
||||
host: null,
|
||||
padding: !a,
|
||||
viewport: t => a && t === t.ownerDocument.body && t,
|
||||
content: false,
|
||||
scrollbarsSlot: true,
|
||||
elements: {
|
||||
host: null,
|
||||
padding: !a,
|
||||
viewport: t => a && t === t.ownerDocument.body && t,
|
||||
content: false
|
||||
},
|
||||
scrollbars: {
|
||||
slot: true
|
||||
},
|
||||
cancel: {
|
||||
nativeScrollbarsOverlaid: false,
|
||||
body: null
|
||||
@@ -1254,103 +1258,105 @@ const createStructureSetupElements = t => {
|
||||
const {Y: o, T: s} = n;
|
||||
const e = getPlugins()[yt];
|
||||
const c = e && e.A;
|
||||
const {host: r, viewport: i, padding: l, content: a} = o();
|
||||
const u = isHTMLElement(t);
|
||||
const d = u ? {} : t;
|
||||
const {host: f, padding: _, viewport: h, content: g} = d;
|
||||
const v = u ? t : d.target;
|
||||
const w = is(v, "textarea");
|
||||
const p = v.ownerDocument;
|
||||
const b = v === p.body;
|
||||
const y = p.defaultView;
|
||||
const m = staticInitializationElement.bind(0, [ v ]);
|
||||
const S = dynamicInitializationElement.bind(0, [ v ]);
|
||||
const x = m(Ct, i, h);
|
||||
const $ = x === v;
|
||||
const A = $ && b;
|
||||
const T = !$ && y.top === y && p.activeElement === v;
|
||||
const z = {
|
||||
X: v,
|
||||
J: w ? m(Ct, r, f) : v,
|
||||
K: x,
|
||||
Z: !$ && S(Ct, l, _),
|
||||
tt: !$ && S(Ct, a, g),
|
||||
nt: !$ && !s && c && c(n),
|
||||
ot: A ? p.documentElement : x,
|
||||
st: A ? p : x,
|
||||
et: y,
|
||||
ct: p,
|
||||
rt: w,
|
||||
W: b,
|
||||
it: u,
|
||||
lt: $,
|
||||
ut: (t, n) => $ ? hasAttrClass(x, C, n) : hasClass(x, t),
|
||||
dt: (t, n, o) => $ ? attrClass(x, C, n, o) : (o ? addClass : removeClass)(x, t)
|
||||
const {elements: r} = o();
|
||||
const {host: i, viewport: l, padding: a, content: u} = r;
|
||||
const d = isHTMLElement(t);
|
||||
const f = d ? {} : t;
|
||||
const {elements: _} = f;
|
||||
const {host: h, padding: g, viewport: v, content: w} = _ || {};
|
||||
const p = d ? t : f.target;
|
||||
const b = is(p, "textarea");
|
||||
const y = p.ownerDocument;
|
||||
const m = p === y.body;
|
||||
const S = y.defaultView;
|
||||
const x = staticInitializationElement.bind(0, [ p ]);
|
||||
const $ = dynamicInitializationElement.bind(0, [ p ]);
|
||||
const A = x(Ct, l, v);
|
||||
const T = A === p;
|
||||
const z = T && m;
|
||||
const H = !T && S.top === S && y.activeElement === p;
|
||||
const M = {
|
||||
X: p,
|
||||
J: b ? x(Ct, i, h) : p,
|
||||
K: A,
|
||||
Z: !T && $(Ct, a, g),
|
||||
tt: !T && $(Ct, u, w),
|
||||
nt: !T && !s && c && c(n),
|
||||
ot: z ? y.documentElement : A,
|
||||
st: z ? y : A,
|
||||
et: S,
|
||||
ct: y,
|
||||
rt: b,
|
||||
W: m,
|
||||
it: d,
|
||||
lt: T,
|
||||
ut: (t, n) => T ? hasAttrClass(A, C, n) : hasClass(A, t),
|
||||
dt: (t, n, o) => T ? attrClass(A, C, n, o) : (o ? addClass : removeClass)(A, t)
|
||||
};
|
||||
const H = keys(z).reduce(((t, n) => {
|
||||
const o = z[n];
|
||||
const R = keys(M).reduce(((t, n) => {
|
||||
const o = M[n];
|
||||
return push(t, o && !parent(o) ? o : false);
|
||||
}), []);
|
||||
const elementIsGenerated = t => t ? indexOf(H, t) > -1 : null;
|
||||
const {X: M, J: R, Z: k, K: B, tt: V, nt: j} = z;
|
||||
const Y = [];
|
||||
const q = w && elementIsGenerated(R);
|
||||
let F = w ? M : contents([ V, B, k, R, M ].find((t => false === elementIsGenerated(t))));
|
||||
const G = V || B;
|
||||
const elementIsGenerated = t => t ? indexOf(R, t) > -1 : null;
|
||||
const {X: k, J: B, Z: V, K: j, tt: Y, nt: q} = M;
|
||||
const F = [];
|
||||
const G = b && elementIsGenerated(B);
|
||||
let N = b ? k : contents([ Y, j, V, B, k ].find((t => false === elementIsGenerated(t))));
|
||||
const U = Y || j;
|
||||
const appendElements = () => {
|
||||
const t = addDataAttrHost(R, $ ? "viewport" : "host");
|
||||
const n = addClass(k, I);
|
||||
const o = addClass(B, !$ && L);
|
||||
const e = addClass(V, P);
|
||||
const c = b ? addClass(parent(v), D) : noop;
|
||||
if (q) {
|
||||
insertAfter(M, R);
|
||||
push(Y, (() => {
|
||||
insertAfter(R, M);
|
||||
removeElements(R);
|
||||
const t = addDataAttrHost(B, T ? "viewport" : "host");
|
||||
const n = addClass(V, I);
|
||||
const o = addClass(j, !T && L);
|
||||
const e = addClass(Y, P);
|
||||
const c = m ? addClass(parent(p), D) : noop;
|
||||
if (G) {
|
||||
insertAfter(k, B);
|
||||
push(F, (() => {
|
||||
insertAfter(B, k);
|
||||
removeElements(B);
|
||||
}));
|
||||
}
|
||||
appendChildren(G, F);
|
||||
appendChildren(R, k);
|
||||
appendChildren(k || R, !$ && B);
|
||||
appendChildren(U, N);
|
||||
appendChildren(B, V);
|
||||
push(Y, (() => {
|
||||
appendChildren(V || B, !T && j);
|
||||
appendChildren(j, Y);
|
||||
push(F, (() => {
|
||||
c();
|
||||
t();
|
||||
removeAttr(B, O);
|
||||
removeAttr(B, E);
|
||||
removeAttr(j, O);
|
||||
removeAttr(j, E);
|
||||
if (elementIsGenerated(Y)) {
|
||||
unwrap(Y);
|
||||
}
|
||||
if (elementIsGenerated(j)) {
|
||||
unwrap(j);
|
||||
}
|
||||
if (elementIsGenerated(V)) {
|
||||
unwrap(V);
|
||||
}
|
||||
if (elementIsGenerated(B)) {
|
||||
unwrap(B);
|
||||
}
|
||||
if (elementIsGenerated(k)) {
|
||||
unwrap(k);
|
||||
}
|
||||
n();
|
||||
o();
|
||||
e();
|
||||
}));
|
||||
if (s && !$) {
|
||||
push(Y, removeClass.bind(0, B, D));
|
||||
if (s && !T) {
|
||||
push(F, removeClass.bind(0, j, D));
|
||||
}
|
||||
if (j) {
|
||||
insertBefore(B, j);
|
||||
push(Y, removeElements.bind(0, j));
|
||||
if (q) {
|
||||
insertBefore(j, q);
|
||||
push(F, removeElements.bind(0, q));
|
||||
}
|
||||
if (T) {
|
||||
const t = attr(B, $t);
|
||||
attr(B, $t, "-1");
|
||||
B.focus();
|
||||
const n = on(p, "pointerdown keydown", (() => {
|
||||
t ? attr(B, $t, t) : removeAttr(B, $t);
|
||||
if (H) {
|
||||
const t = attr(j, $t);
|
||||
attr(j, $t, "-1");
|
||||
j.focus();
|
||||
const n = on(y, "pointerdown keydown", (() => {
|
||||
t ? attr(j, $t, t) : removeAttr(j, $t);
|
||||
n();
|
||||
}));
|
||||
}
|
||||
F = 0;
|
||||
N = 0;
|
||||
};
|
||||
return [ z, appendElements, runEachAndClear.bind(0, Y) ];
|
||||
return [ M, appendElements, runEachAndClear.bind(0, F) ];
|
||||
};
|
||||
|
||||
const createTrinsicUpdateSegment = (t, n) => {
|
||||
@@ -2374,10 +2380,12 @@ const getScrollbarHandleOffsetRatio = (t, n, o, s, e, c) => {
|
||||
|
||||
const createScrollbarsSetupElements = (t, n, o) => {
|
||||
const {Y: s} = getEnvironment();
|
||||
const {scrollbarsSlot: e} = s();
|
||||
const {ct: c, X: r, J: i, K: l, it: a, ot: u} = n;
|
||||
const {scrollbarsSlot: d} = a ? {} : t;
|
||||
const f = dynamicInitializationElement([ r, i, l ], (() => i), e, d);
|
||||
const {scrollbars: e} = s();
|
||||
const {slot: c} = e;
|
||||
const {ct: r, X: i, J: l, K: a, it: u, ot: d} = n;
|
||||
const {scrollbars: f} = u ? {} : t;
|
||||
const {slot: h} = f || {};
|
||||
const g = dynamicInitializationElement([ i, l, a ], (() => l), c, h);
|
||||
const scrollbarStructureAddRemoveClass = (t, n, o) => {
|
||||
const s = o ? addClass : removeClass;
|
||||
each(t, (t => {
|
||||
@@ -2402,75 +2410,75 @@ const createScrollbarsSetupElements = (t, n, o) => {
|
||||
const s = o ? "X" : "Y";
|
||||
scrollbarsHandleStyle(t, (t => {
|
||||
const {qt: e, Ft: c, Gt: r} = t;
|
||||
const i = getScrollbarHandleOffsetRatio(e, c, u, n, directionIsRTL(r), o);
|
||||
const i = getScrollbarHandleOffsetRatio(e, c, d, n, directionIsRTL(r), o);
|
||||
const l = i === i;
|
||||
return [ e, {
|
||||
transform: l ? `translate${s}(${(100 * i).toFixed(3)}%)` : ""
|
||||
} ];
|
||||
}));
|
||||
};
|
||||
const h = [];
|
||||
const g = [];
|
||||
const v = [];
|
||||
const w = [];
|
||||
const p = [];
|
||||
const scrollbarsAddRemoveClass = (t, n, o) => {
|
||||
const s = isBoolean(o);
|
||||
const e = s ? o : true;
|
||||
const c = s ? !o : true;
|
||||
e && scrollbarStructureAddRemoveClass(g, t, n);
|
||||
c && scrollbarStructureAddRemoveClass(v, t, n);
|
||||
e && scrollbarStructureAddRemoveClass(w, t, n);
|
||||
c && scrollbarStructureAddRemoveClass(p, t, n);
|
||||
};
|
||||
const refreshScrollbarsHandleLength = t => {
|
||||
scrollbarStructureRefreshHandleLength(g, t, true);
|
||||
scrollbarStructureRefreshHandleLength(v, t);
|
||||
scrollbarStructureRefreshHandleLength(w, t, true);
|
||||
scrollbarStructureRefreshHandleLength(p, t);
|
||||
};
|
||||
const refreshScrollbarsHandleOffset = t => {
|
||||
scrollbarStructureRefreshHandleOffset(g, t, true);
|
||||
scrollbarStructureRefreshHandleOffset(v, t);
|
||||
scrollbarStructureRefreshHandleOffset(w, t, true);
|
||||
scrollbarStructureRefreshHandleOffset(p, t);
|
||||
};
|
||||
const generateScrollbarDOM = t => {
|
||||
const n = t ? N : U;
|
||||
const s = t ? g : v;
|
||||
const s = t ? w : p;
|
||||
const e = isEmptyArray(s) ? Z : "";
|
||||
const r = createDiv(`${F} ${n} ${e}`);
|
||||
const c = createDiv(`${F} ${n} ${e}`);
|
||||
const i = createDiv(W);
|
||||
const l = createDiv(X);
|
||||
const a = {
|
||||
Gt: r,
|
||||
Gt: c,
|
||||
Ft: i,
|
||||
qt: l
|
||||
};
|
||||
appendChildren(r, i);
|
||||
appendChildren(c, i);
|
||||
appendChildren(i, l);
|
||||
push(s, a);
|
||||
push(h, [ removeElements.bind(0, r), o(a, scrollbarsAddRemoveClass, c, u, t) ]);
|
||||
push(v, [ removeElements.bind(0, c), o(a, scrollbarsAddRemoveClass, r, d, t) ]);
|
||||
return a;
|
||||
};
|
||||
const w = generateScrollbarDOM.bind(0, true);
|
||||
const p = generateScrollbarDOM.bind(0, false);
|
||||
const b = generateScrollbarDOM.bind(0, true);
|
||||
const y = generateScrollbarDOM.bind(0, false);
|
||||
const appendElements = () => {
|
||||
appendChildren(f, g[0].Gt);
|
||||
appendChildren(f, v[0].Gt);
|
||||
appendChildren(g, w[0].Gt);
|
||||
appendChildren(g, p[0].Gt);
|
||||
_((() => {
|
||||
scrollbarsAddRemoveClass(Z);
|
||||
}), 300);
|
||||
};
|
||||
w();
|
||||
p();
|
||||
b();
|
||||
y();
|
||||
return [ {
|
||||
Nt: refreshScrollbarsHandleLength,
|
||||
Ut: refreshScrollbarsHandleOffset,
|
||||
Wt: scrollbarsAddRemoveClass,
|
||||
Xt: {
|
||||
Jt: g,
|
||||
Kt: w,
|
||||
Zt: scrollbarsHandleStyle.bind(0, g)
|
||||
Jt: w,
|
||||
Kt: b,
|
||||
Zt: scrollbarsHandleStyle.bind(0, w)
|
||||
},
|
||||
Qt: {
|
||||
Jt: v,
|
||||
Kt: p,
|
||||
Zt: scrollbarsHandleStyle.bind(0, v)
|
||||
Jt: p,
|
||||
Kt: y,
|
||||
Zt: scrollbarsHandleStyle.bind(0, p)
|
||||
}
|
||||
}, appendElements, runEachAndClear.bind(0, h) ];
|
||||
}, appendElements, runEachAndClear.bind(0, v) ];
|
||||
};
|
||||
|
||||
const createSelfCancelTimeout = t => {
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -153,11 +153,16 @@ const createEnvironment = (): InternalEnvironment => {
|
||||
y: nativeScrollbarsSize.y === 0,
|
||||
};
|
||||
const staticDefaultInitialization: Initialization = {
|
||||
host: null,
|
||||
padding: !nativeScrollbarsHiding,
|
||||
viewport: (target) => nativeScrollbarsHiding && target === target.ownerDocument.body && target,
|
||||
content: false,
|
||||
scrollbarsSlot: true,
|
||||
elements: {
|
||||
host: null,
|
||||
padding: !nativeScrollbarsHiding,
|
||||
viewport: (target) =>
|
||||
nativeScrollbarsHiding && target === target.ownerDocument.body && target,
|
||||
content: false,
|
||||
},
|
||||
scrollbars: {
|
||||
slot: true,
|
||||
},
|
||||
cancel: {
|
||||
nativeScrollbarsOverlaid: false,
|
||||
body: null,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { isFunction, isHTMLElement, isNull, isUndefined } from 'support';
|
||||
import type { StructureInitialization } from 'setups/structureSetup';
|
||||
import type { ScrollbarsInitialization } from 'setups/scrollbarsSetup';
|
||||
import { getEnvironment } from 'environment';
|
||||
import { DeepPartial } from 'typings';
|
||||
import { StructureSetupElementsObj } from 'setups/structureSetup/structureSetup.elements';
|
||||
@@ -8,13 +6,47 @@ import { StructureSetupElementsObj } from 'setups/structureSetup/structureSetup.
|
||||
type StaticInitialization = HTMLElement | false | null;
|
||||
type DynamicInitialization = HTMLElement | boolean | null;
|
||||
|
||||
export type Initialization = StructureInitialization &
|
||||
ScrollbarsInitialization & {
|
||||
cancel: {
|
||||
nativeScrollbarsOverlaid: boolean;
|
||||
body: boolean | null;
|
||||
};
|
||||
type FallbackInitializtationElement<
|
||||
InitElm extends StaticInitializationElement<any> | DynamicInitializationElement<any>
|
||||
> = Extract<InitElm, (...args: any[]) => any> extends (...args: infer P) => any
|
||||
? (...args: P) => HTMLElement
|
||||
: never;
|
||||
|
||||
/**
|
||||
* Static elements are elements which MUST be present in the final DOM.
|
||||
* With false, null or undefined the element will be generated, otherwise the specified element is taken.
|
||||
*/
|
||||
export type StaticInitializationElement<Args extends any[]> =
|
||||
| ((...args: Args) => StaticInitialization)
|
||||
| StaticInitialization;
|
||||
|
||||
/**
|
||||
* Dynamic element are elements which CAN be present in the final DOM.
|
||||
* If its a element the element will be taken as the repsective element.
|
||||
* With true the element will be generated.
|
||||
* With false, null or undefined the element won't be generated and wont be in the DOM.
|
||||
*/
|
||||
export type DynamicInitializationElement<Args extends any[]> =
|
||||
| ((...args: Args) => DynamicInitialization)
|
||||
| DynamicInitialization;
|
||||
|
||||
export type Initialization = {
|
||||
elements: {
|
||||
host: StaticInitializationElement<[target: InitializationTargetElement]>; // only relevant for textarea
|
||||
viewport: StaticInitializationElement<[target: InitializationTargetElement]>;
|
||||
padding: DynamicInitializationElement<[target: InitializationTargetElement]>;
|
||||
content: DynamicInitializationElement<[target: InitializationTargetElement]>;
|
||||
};
|
||||
scrollbars: {
|
||||
slot: DynamicInitializationElement<
|
||||
[target: InitializationTargetElement, host: HTMLElement, viewport: HTMLElement]
|
||||
>;
|
||||
};
|
||||
cancel: {
|
||||
nativeScrollbarsOverlaid: boolean;
|
||||
body: boolean | null;
|
||||
};
|
||||
};
|
||||
|
||||
export type InitializationTargetElement = HTMLElement | HTMLTextAreaElement;
|
||||
|
||||
@@ -24,30 +56,6 @@ export type InitializationTargetObject = DeepPartial<Initialization> & {
|
||||
|
||||
export type InitializationTarget = InitializationTargetElement | InitializationTargetObject;
|
||||
|
||||
/**
|
||||
* Static elements MUST be present.
|
||||
* With false, null or undefined the element will be generated, otherwise the specified element is taken.
|
||||
*/
|
||||
export type StaticInitializationElement<Args extends any[]> =
|
||||
| ((...args: Args) => StaticInitialization)
|
||||
| StaticInitialization;
|
||||
|
||||
/**
|
||||
* Dynamic element CAN be present.
|
||||
* If its a element the element will be taken as the repsective element.
|
||||
* With true the element will be generated.
|
||||
* With false, null or undefined the element won't be generated.
|
||||
*/
|
||||
export type DynamicInitializationElement<Args extends any[]> =
|
||||
| ((...args: Args) => DynamicInitialization)
|
||||
| DynamicInitialization;
|
||||
|
||||
export type FallbackInitializtationElement<
|
||||
InitElm extends StaticInitializationElement<any> | DynamicInitializationElement<any>
|
||||
> = Extract<InitElm, (...args: any[]) => any> extends (...args: infer P) => any
|
||||
? (...args: P) => HTMLElement
|
||||
: never;
|
||||
|
||||
const resolveInitialization = <T>(value: any, args: any): T =>
|
||||
isFunction(value) ? value.apply(0, args) : value;
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export * from 'setups/scrollbarsSetup/scrollbarsSetup';
|
||||
export * from 'setups/scrollbarsSetup/scrollbarsSetup.initialization';
|
||||
|
||||
@@ -27,13 +27,13 @@ import {
|
||||
getScrollbarHandleLengthRatio,
|
||||
getScrollbarHandleOffsetRatio,
|
||||
} from 'setups/scrollbarsSetup/scrollbarsSetup.calculations';
|
||||
import type { InitializationTarget } from 'initialization';
|
||||
import type {
|
||||
Initialization,
|
||||
InitializationTarget,
|
||||
InitializationTargetObject,
|
||||
} from 'initialization';
|
||||
import type { StructureSetupElementsObj } from 'setups/structureSetup/structureSetup.elements';
|
||||
import type { ScrollbarsSetupEvents } from 'setups/scrollbarsSetup/scrollbarsSetup.events';
|
||||
import type {
|
||||
ScrollbarsInitialization,
|
||||
ScrollbarsDynamicInitializationElement,
|
||||
} from 'setups/scrollbarsSetup/scrollbarsSetup.initialization';
|
||||
import type { StyleObject } from 'typings';
|
||||
import { StructureSetupState } from 'setups';
|
||||
|
||||
@@ -77,17 +77,15 @@ export const createScrollbarsSetupElements = (
|
||||
scrollbarsSetupEvents: ScrollbarsSetupEvents
|
||||
): ScrollbarsSetupElements => {
|
||||
const { _getDefaultInitialization } = getEnvironment();
|
||||
const { scrollbarsSlot: defaultScrollbarsSlot } = _getDefaultInitialization();
|
||||
const { scrollbars: defaultInitScrollbars } = _getDefaultInitialization();
|
||||
const { slot: defaultInitScrollbarsSlot } = defaultInitScrollbars;
|
||||
const { _documentElm, _target, _host, _viewport, _targetIsElm, _scrollOffsetElement } =
|
||||
structureSetupElements;
|
||||
const { scrollbarsSlot } = (_targetIsElm ? {} : target) as ScrollbarsInitialization;
|
||||
const evaluatedScrollbarSlot =
|
||||
generalDynamicInitializationElement<ScrollbarsDynamicInitializationElement>(
|
||||
[_target, _host, _viewport],
|
||||
() => _host,
|
||||
defaultScrollbarsSlot,
|
||||
scrollbarsSlot
|
||||
);
|
||||
const { scrollbars: scrollbarsInit } = (_targetIsElm ? {} : target) as InitializationTargetObject;
|
||||
const { slot: initScrollbarsSlot } = scrollbarsInit || {};
|
||||
const evaluatedScrollbarSlot = generalDynamicInitializationElement<
|
||||
Initialization['scrollbars']['slot']
|
||||
>([_target, _host, _viewport], () => _host, defaultInitScrollbarsSlot, initScrollbarsSlot);
|
||||
const scrollbarStructureAddRemoveClass = (
|
||||
scrollbarStructures: ScrollbarStructure[],
|
||||
classNames: string | false | null | undefined,
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
import type { InitializationTargetElement, DynamicInitializationElement } from 'initialization';
|
||||
|
||||
export type ScrollbarsDynamicInitializationElement = DynamicInitializationElement<
|
||||
[target: InitializationTargetElement, host: HTMLElement, viewport: HTMLElement]
|
||||
>;
|
||||
|
||||
/**
|
||||
* Object for special initialization.
|
||||
*
|
||||
* If element is provided, the provided element takes all its responsibilities.
|
||||
* DOM hierarchy isn't checked in this case, its assumed that hieararchy is correct in such a case.
|
||||
*
|
||||
* Null or Undefined means that the environment initialization strategy is used.
|
||||
*/
|
||||
export interface ScrollbarsInitialization {
|
||||
scrollbarsSlot: ScrollbarsDynamicInitializationElement;
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
export * from 'setups/structureSetup/structureSetup';
|
||||
export * from 'setups/structureSetup/structureSetup.initialization';
|
||||
|
||||
@@ -39,14 +39,11 @@ import {
|
||||
dynamicInitializationElement as generalDynamicInitializationElement,
|
||||
} from 'initialization';
|
||||
import type {
|
||||
Initialization,
|
||||
InitializationTarget,
|
||||
InitializationTargetElement,
|
||||
InitializationTargetObject,
|
||||
} from 'initialization';
|
||||
import type {
|
||||
StructureDynamicInitializationElement,
|
||||
StructureStaticInitializationElement,
|
||||
} from 'setups/structureSetup/structureSetup.initialization';
|
||||
|
||||
export type StructureSetupElements = [
|
||||
targetObj: StructureSetupElementsObj,
|
||||
@@ -97,34 +94,34 @@ export const createStructureSetupElements = (
|
||||
| undefined;
|
||||
const createUniqueViewportArrangeElement =
|
||||
scrollbarsHidingPlugin && scrollbarsHidingPlugin._createUniqueViewportArrangeElement;
|
||||
const { elements: defaultInitElements } = _getDefaultInitialization();
|
||||
const {
|
||||
host: defaultHostInitialization,
|
||||
viewport: defaultViewportInitialization,
|
||||
padding: defaultPaddingInitialization,
|
||||
content: defaultContentInitialization,
|
||||
} = _getDefaultInitialization();
|
||||
} = defaultInitElements;
|
||||
const targetIsElm = isHTMLElement(target);
|
||||
const targetStructureInitialization = (targetIsElm ? {} : target) as InitializationTargetObject;
|
||||
const { elements: initElements } = targetStructureInitialization;
|
||||
const {
|
||||
host: hostInitialization,
|
||||
padding: paddingInitialization,
|
||||
viewport: viewportInitialization,
|
||||
content: contentInitialization,
|
||||
} = targetStructureInitialization;
|
||||
} = initElements || {};
|
||||
|
||||
const targetElement = targetIsElm ? target : targetStructureInitialization.target;
|
||||
const isTextarea = is(targetElement, 'textarea');
|
||||
const ownerDocument = targetElement.ownerDocument;
|
||||
const isBody = targetElement === ownerDocument.body;
|
||||
const wnd = ownerDocument.defaultView as Window;
|
||||
const staticInitializationElement =
|
||||
generalStaticInitializationElement<StructureStaticInitializationElement>.bind(0, [
|
||||
targetElement,
|
||||
]);
|
||||
const dynamicInitializationElement =
|
||||
generalDynamicInitializationElement<StructureDynamicInitializationElement>.bind(0, [
|
||||
targetElement,
|
||||
]);
|
||||
const staticInitializationElement = generalStaticInitializationElement<
|
||||
Initialization['elements']['viewport']
|
||||
>.bind(0, [targetElement]);
|
||||
const dynamicInitializationElement = generalDynamicInitializationElement<
|
||||
Initialization['elements']['content']
|
||||
>.bind(0, [targetElement]);
|
||||
const viewportElement = staticInitializationElement(
|
||||
createNewDiv,
|
||||
defaultViewportInitialization,
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import type {
|
||||
InitializationTargetElement,
|
||||
StaticInitializationElement,
|
||||
DynamicInitializationElement,
|
||||
} from 'initialization';
|
||||
|
||||
export type StructureStaticInitializationElement = StaticInitializationElement<
|
||||
[target: InitializationTargetElement]
|
||||
>;
|
||||
|
||||
export type StructureDynamicInitializationElement = DynamicInitializationElement<
|
||||
[target: InitializationTargetElement]
|
||||
>;
|
||||
|
||||
/**
|
||||
* Object for special initialization.
|
||||
*
|
||||
* Target is always required, if element is not provided or undefined it will be generated.
|
||||
*
|
||||
* If element is provided, the provided element takes all its responsibilities.
|
||||
* DOM hierarchy isn't checked in this case, its assumed that hieararchy is correct in such a case.
|
||||
*
|
||||
* undefined means that the default initialization strategy is used.
|
||||
*/
|
||||
export interface StructureInitialization {
|
||||
host: StructureStaticInitializationElement; // only relevant for textarea
|
||||
viewport: StructureStaticInitializationElement;
|
||||
padding: StructureDynamicInitializationElement;
|
||||
content: StructureDynamicInitializationElement;
|
||||
}
|
||||
@@ -90,22 +90,6 @@ export function style<CustomCssProps>(
|
||||
elm && each(keys(styles), (key) => setCSSVal(elm, key, styles[key]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the passed element (display: none).
|
||||
* @param elm The element which shall be hidden.
|
||||
*/
|
||||
export const hide = (elm: HTMLElement | false | null | undefined): void => {
|
||||
style(elm, { display: 'none' });
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows the passed element (display: block).
|
||||
* @param elm The element which shall be shown.
|
||||
*/
|
||||
export const show = (elm: HTMLElement | false | null | undefined): void => {
|
||||
style(elm, { display: 'block' });
|
||||
};
|
||||
|
||||
export const directionIsRTL = (elm: HTMLElement | false | null | undefined): boolean =>
|
||||
style(elm, 'direction') === 'rtl';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export * from 'support/utils/array';
|
||||
export * from 'support/utils/equal';
|
||||
export * from 'support/utils/function';
|
||||
export * from 'support/utils/lexicon';
|
||||
export * from 'support/utils/object';
|
||||
export * from 'support/utils/types';
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
interface GenericLexicon<T extends boolean> {
|
||||
_widthHeight: T extends true ? 'width' : 'height';
|
||||
_WidthHeight: T extends true ? 'Width' : 'Height';
|
||||
_leftTop: T extends true ? 'left' : 'top';
|
||||
_LeftTop: T extends true ? 'Left' : 'Top';
|
||||
_xy: T extends true ? 'x' : 'y';
|
||||
_XY: T extends true ? 'X' : 'Y';
|
||||
_wh: T extends true ? 'w' : 'h';
|
||||
_lt: T extends true ? 'l' : 't';
|
||||
}
|
||||
|
||||
export type Lexicon<T extends boolean> = GenericLexicon<T>
|
||||
|
||||
export const getLexicon = <T extends boolean = false>(horizontal?: T): Lexicon<T> =>
|
||||
({
|
||||
_widthHeight: horizontal ? 'width' : 'height',
|
||||
_WidthHeight: horizontal ? 'Width' : 'Height',
|
||||
_leftTop: horizontal ? 'left' : 'top',
|
||||
_LeftTop: horizontal ? 'Left' : 'Top',
|
||||
_xy: horizontal ? 'x' : 'y',
|
||||
_XY: horizontal ? 'X' : 'Y',
|
||||
_wh: horizontal ? 'w' : 'h',
|
||||
_lt: horizontal ? 'l' : 't',
|
||||
// _inverted: getLexicon(!horizontal),
|
||||
} as Lexicon<T>);
|
||||
@@ -1,5 +1,5 @@
|
||||
import { addInstance, removeInstance, getInstance } from 'instances';
|
||||
import { OverlayScrollbars } from 'overlayscrollbars';
|
||||
import { OverlayScrollbars } from '../../src/overlayscrollbars';
|
||||
|
||||
const testElm = document.body;
|
||||
const testInstance = OverlayScrollbars(document.body, {});
|
||||
|
||||
+178
-107
@@ -6,12 +6,11 @@ import {
|
||||
StructureSetupElementsObj,
|
||||
} from 'setups/structureSetup/structureSetup.elements';
|
||||
import { addPlugin, scrollbarsHidingPlugin } from 'plugins';
|
||||
import type { InitializationTarget } from 'initialization';
|
||||
import type {
|
||||
StructureInitialization,
|
||||
StructureStaticInitializationElement,
|
||||
StructureDynamicInitializationElement,
|
||||
} from 'setups/structureSetup/structureSetup.initialization';
|
||||
Initialization,
|
||||
InitializationTarget,
|
||||
InitializationTargetObject,
|
||||
} from 'initialization';
|
||||
|
||||
const mockGetEnvironment = jest.fn();
|
||||
jest.mock('environment', () => ({
|
||||
@@ -35,6 +34,8 @@ interface StructureSetupElementsProxy {
|
||||
}
|
||||
|
||||
type TargetType = 'element' | 'textarea' | 'body';
|
||||
type StructureStaticInitializationElement = Initialization['elements']['viewport'];
|
||||
type StructureDynamicInitializationElement = Initialization['elements']['content'];
|
||||
|
||||
const textareaId = 'textarea';
|
||||
const textareaHostId = 'host';
|
||||
@@ -132,9 +133,7 @@ const assertCorrectDOMStructure = (targetType: TargetType, viewportIsTarget: boo
|
||||
}
|
||||
};
|
||||
|
||||
const createStructureSetupProxy = (
|
||||
target: InitializationTarget | StructureInitialization
|
||||
): StructureSetupElementsProxy => {
|
||||
const createStructureSetupProxy = (target: InitializationTarget): StructureSetupElementsProxy => {
|
||||
const [elements, appendElements, destroy] = createStructureSetupElements(target);
|
||||
appendElements();
|
||||
return {
|
||||
@@ -210,14 +209,15 @@ const assertCorrectSetupElements = (
|
||||
expect(typeof destroy).toBe('function');
|
||||
|
||||
const { _nativeScrollbarsHiding, _cssCustomProperties, _getDefaultInitialization } = environment;
|
||||
const { elements: defaultInitElements } = _getDefaultInitialization();
|
||||
const {
|
||||
host: hostInitStrategy,
|
||||
viewport: viewportInitStrategy,
|
||||
padding: paddingInitStrategy,
|
||||
content: contentInitStrategy,
|
||||
} = _getDefaultInitialization();
|
||||
} = defaultInitElements;
|
||||
const inputIsElement = isHTMLElement(input);
|
||||
const inputAsObj = input as StructureInitialization;
|
||||
const inputAsObj = input as InitializationTargetObject;
|
||||
const styleElm = document.querySelector('style');
|
||||
const checkStrategyDependendElements = (
|
||||
elm: Element | null,
|
||||
@@ -289,12 +289,13 @@ const assertCorrectSetupElements = (
|
||||
checkStrategyDependendElements(viewport, undefined, true, viewportInitStrategy, 'viewport');
|
||||
checkStrategyDependendElements(host, undefined, true, hostInitStrategy, 'host');
|
||||
} else {
|
||||
const { elements: inputElements } = inputAsObj;
|
||||
const {
|
||||
padding: inputPadding,
|
||||
content: inputContent,
|
||||
viewport: inputViewport,
|
||||
host: inputHost,
|
||||
} = inputAsObj;
|
||||
} = inputElements || {};
|
||||
checkStrategyDependendElements(padding, inputPadding, false, paddingInitStrategy, 'padding');
|
||||
checkStrategyDependendElements(content, inputContent, false, contentInitStrategy, 'content');
|
||||
checkStrategyDependendElements(viewport, inputViewport, true, viewportInitStrategy, 'viewport');
|
||||
@@ -364,10 +365,13 @@ const envInitStrategyMin = {
|
||||
...env,
|
||||
_getDefaultInitialization: () => ({
|
||||
...env._staticDefaultInitialization,
|
||||
host: null,
|
||||
viewport: () => null,
|
||||
content: () => false,
|
||||
padding: false,
|
||||
elements: {
|
||||
...env._staticDefaultInitialization.elements,
|
||||
host: null,
|
||||
viewport: () => null,
|
||||
content: () => false,
|
||||
padding: false,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
@@ -377,10 +381,13 @@ const envInitStrategyMax = {
|
||||
...env,
|
||||
_getDefaultInitialization: () => ({
|
||||
...env._staticDefaultInitialization,
|
||||
host: null,
|
||||
viewport: null,
|
||||
content: true,
|
||||
padding: () => true,
|
||||
elements: {
|
||||
...env._staticDefaultInitialization.elements,
|
||||
host: null,
|
||||
viewport: null,
|
||||
content: true,
|
||||
padding: () => true,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
@@ -390,10 +397,13 @@ const envInitStrategyAssigned = {
|
||||
...env,
|
||||
_getDefaultInitialization: () => ({
|
||||
...env._staticDefaultInitialization,
|
||||
host: () => document.querySelector('#host1') as HTMLElement,
|
||||
viewport: (target: HTMLElement) => target.querySelector('#viewport') as HTMLElement,
|
||||
content: (target: HTMLElement) => target.querySelector<HTMLElement>('#content'),
|
||||
padding: (target: HTMLElement) => target.querySelector<HTMLElement>('#padding'),
|
||||
elements: {
|
||||
...env._staticDefaultInitialization.elements,
|
||||
host: () => document.querySelector('#host1') as HTMLElement,
|
||||
viewport: (target: HTMLElement) => target.querySelector('#viewport') as HTMLElement,
|
||||
content: (target: HTMLElement) => target.querySelector<HTMLElement>('#content'),
|
||||
padding: (target: HTMLElement) => target.querySelector<HTMLElement>('#padding'),
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
@@ -404,7 +414,10 @@ const envInitStrategyViewportIsTarget = {
|
||||
_nativeScrollbarsHiding: true,
|
||||
_getDefaultInitialization: () => ({
|
||||
...env._staticDefaultInitialization,
|
||||
viewport: (target: HTMLElement) => !is(target, 'textarea') && target,
|
||||
elements: {
|
||||
...env._staticDefaultInitialization.elements,
|
||||
viewport: (target: HTMLElement) => !is(target, 'textarea') && target,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
@@ -464,9 +477,11 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: () => document.querySelector<HTMLElement>('#padding')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: () => document.querySelector<HTMLElement>('#padding'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -483,9 +498,11 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: () => document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
elements: {
|
||||
host: () => document.querySelector<HTMLElement>('#host'),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -502,9 +519,11 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
content: document.querySelector<HTMLElement>('#content')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
content: document.querySelector<HTMLElement>('#content'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -523,11 +542,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: document.querySelector<HTMLElement>('#padding')!,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: () => document.querySelector<HTMLElement>('#content')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: document.querySelector<HTMLElement>('#padding'),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
content: () => document.querySelector<HTMLElement>('#content'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -544,10 +565,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: () => document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: document.querySelector<HTMLElement>('#padding')!,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
elements: {
|
||||
host: () => document.querySelector<HTMLElement>('#host'),
|
||||
padding: document.querySelector<HTMLElement>('#padding'),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -564,10 +587,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: () => document.querySelector<HTMLElement>('#padding')!,
|
||||
content: document.querySelector<HTMLElement>('#content')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: () => document.querySelector<HTMLElement>('#padding'),
|
||||
content: document.querySelector<HTMLElement>('#content'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -584,10 +609,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: () => document.querySelector<HTMLElement>('#content')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
content: () => document.querySelector<HTMLElement>('#content'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -603,7 +630,9 @@ describe('structureSetup', () => {
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
target: getTarget(targetType),
|
||||
padding: false,
|
||||
elements: {
|
||||
padding: false,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -617,7 +646,9 @@ describe('structureSetup', () => {
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
target: getTarget(targetType),
|
||||
content: () => false,
|
||||
elements: {
|
||||
content: () => false,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -633,7 +664,9 @@ describe('structureSetup', () => {
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
target: getTarget(targetType),
|
||||
padding: () => true,
|
||||
elements: {
|
||||
padding: () => true,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -647,7 +680,9 @@ describe('structureSetup', () => {
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
target: getTarget(targetType),
|
||||
content: true,
|
||||
elements: {
|
||||
content: true,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -663,8 +698,10 @@ describe('structureSetup', () => {
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
target: getTarget(targetType),
|
||||
padding: false,
|
||||
content: false,
|
||||
elements: {
|
||||
padding: false,
|
||||
content: false,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -680,8 +717,10 @@ describe('structureSetup', () => {
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
target: getTarget(targetType),
|
||||
padding: true,
|
||||
content: true,
|
||||
elements: {
|
||||
padding: true,
|
||||
content: true,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -700,11 +739,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: false,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: false,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: false,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
content: false,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -721,11 +762,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: true,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: true,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: true,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
content: true,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -742,11 +785,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: () => false,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: () => true,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: () => false,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
content: () => true,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -763,11 +808,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: true,
|
||||
viewport: () => document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: false,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: true,
|
||||
viewport: () => document.querySelector<HTMLElement>('#viewport'),
|
||||
content: false,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -784,10 +831,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: false,
|
||||
content: document.querySelector<HTMLElement>('#content')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: false,
|
||||
content: document.querySelector<HTMLElement>('#content'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -804,10 +853,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: true,
|
||||
content: document.querySelector<HTMLElement>('#content')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: true,
|
||||
content: document.querySelector<HTMLElement>('#content'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -824,10 +875,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: () => false,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: () => false,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -844,10 +897,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: true,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: true,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -864,11 +919,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
padding: false,
|
||||
content: () => document.querySelector<HTMLElement>('#content')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
padding: false,
|
||||
content: () => document.querySelector<HTMLElement>('#content'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -885,11 +942,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
viewport: () => document.querySelector<HTMLElement>('#viewport')!,
|
||||
padding: true,
|
||||
content: document.querySelector<HTMLElement>('#content')!,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
viewport: () => document.querySelector<HTMLElement>('#viewport'),
|
||||
padding: true,
|
||||
content: document.querySelector<HTMLElement>('#content'),
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -906,10 +965,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: document.querySelector<HTMLElement>('#padding')!,
|
||||
content: false,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: document.querySelector<HTMLElement>('#padding'),
|
||||
content: false,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -926,10 +987,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: () => document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: document.querySelector<HTMLElement>('#padding')!,
|
||||
content: true,
|
||||
elements: {
|
||||
host: () => document.querySelector<HTMLElement>('#host'),
|
||||
padding: document.querySelector<HTMLElement>('#padding'),
|
||||
content: true,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -946,10 +1009,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
viewport: () => document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: false,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
viewport: () => document.querySelector<HTMLElement>('#viewport'),
|
||||
content: false,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -966,10 +1031,12 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: true,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
content: true,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -986,11 +1053,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: () => document.querySelector<HTMLElement>('#padding')!,
|
||||
viewport: document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: () => false,
|
||||
elements: {
|
||||
host: document.querySelector<HTMLElement>('#host'),
|
||||
padding: () => document.querySelector<HTMLElement>('#padding'),
|
||||
viewport: document.querySelector<HTMLElement>('#viewport'),
|
||||
content: () => false,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
@@ -1007,11 +1076,13 @@ describe('structureSetup', () => {
|
||||
const [elements, destroy] = assertCorrectSetupElements(
|
||||
targetType,
|
||||
createStructureSetupProxy({
|
||||
host: () => document.querySelector<HTMLElement>('#host')!,
|
||||
target: getTarget(targetType),
|
||||
padding: document.querySelector<HTMLElement>('#padding')!,
|
||||
viewport: () => document.querySelector<HTMLElement>('#viewport')!,
|
||||
content: true,
|
||||
elements: {
|
||||
host: () => document.querySelector<HTMLElement>('#host'),
|
||||
padding: document.querySelector<HTMLElement>('#padding'),
|
||||
viewport: () => document.querySelector<HTMLElement>('#viewport'),
|
||||
content: true,
|
||||
},
|
||||
}),
|
||||
currEnv
|
||||
);
|
||||
|
||||
@@ -128,10 +128,19 @@ describe('dom attributes', () => {
|
||||
setScrollLeft(0);
|
||||
});
|
||||
|
||||
test('null', () => {
|
||||
test('element null', () => {
|
||||
expect(scrollLeft(null)).toBe(0);
|
||||
expect(scrollLeft(null, 0)).toBe(undefined);
|
||||
});
|
||||
|
||||
test('value null', () => {
|
||||
scrollLeft(testElm, 100);
|
||||
expect(scrollLeft(testElm)).toBe(100);
|
||||
scrollLeft(testElm, null);
|
||||
expect(scrollLeft(testElm)).toBe(100);
|
||||
scrollLeft(testElm, 0);
|
||||
expect(scrollLeft(testElm)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('scrollTop', () => {
|
||||
@@ -147,10 +156,19 @@ describe('dom attributes', () => {
|
||||
setScrollTop(0);
|
||||
});
|
||||
|
||||
test('null', () => {
|
||||
test('element null', () => {
|
||||
expect(scrollTop(null)).toBe(0);
|
||||
expect(scrollTop(null, 0)).toBe(undefined);
|
||||
});
|
||||
|
||||
test('value null', () => {
|
||||
scrollTop(testElm, 100);
|
||||
expect(scrollTop(testElm)).toBe(100);
|
||||
scrollTop(testElm, null);
|
||||
expect(scrollTop(testElm)).toBe(100);
|
||||
scrollTop(testElm, 0);
|
||||
expect(scrollTop(testElm)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('val', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { isEmptyObject } from 'support/utils/object';
|
||||
import { isString, isPlainObject } from 'support/utils/types';
|
||||
import { style, hide, show, topRightBottomLeft, directionIsRTL } from 'support/dom/style';
|
||||
import { style, topRightBottomLeft, directionIsRTL } from 'support/dom/style';
|
||||
|
||||
describe('dom style', () => {
|
||||
afterEach(() => {
|
||||
@@ -80,30 +80,6 @@ describe('dom style', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('hide', () => {
|
||||
test('normal', () => {
|
||||
expect(document.body.style.display).toBe('');
|
||||
hide(document.body);
|
||||
expect(document.body.style.display).toBe('none');
|
||||
});
|
||||
|
||||
test('null', () => {
|
||||
expect(hide(null)).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('show', () => {
|
||||
test('normal', () => {
|
||||
expect(document.body.style.display).toBe('');
|
||||
show(document.body);
|
||||
expect(document.body.style.display).toBe('block');
|
||||
});
|
||||
|
||||
test('null', () => {
|
||||
expect(show(null)).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('topRightBottomLeft', () => {
|
||||
describe('without prefix and suffix', () => {
|
||||
test('normal', () => {
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { getLexicon } from 'support/utils/lexicon';
|
||||
|
||||
describe('getLexicon', () => {
|
||||
test('Get vertical Lexicon', () => {
|
||||
const lexicon = getLexicon();
|
||||
expect(lexicon._widthHeight).toBe('height');
|
||||
expect(lexicon._WidthHeight).toBe('Height');
|
||||
expect(lexicon._leftTop).toBe('top');
|
||||
expect(lexicon._LeftTop).toBe('Top');
|
||||
expect(lexicon._xy).toBe('y');
|
||||
expect(lexicon._XY).toBe('Y');
|
||||
expect(lexicon._wh).toBe('h');
|
||||
expect(lexicon._lt).toBe('t');
|
||||
});
|
||||
|
||||
test('Get horizontal Lexicon', () => {
|
||||
const lexicon = getLexicon(true);
|
||||
expect(lexicon._widthHeight).toBe('width');
|
||||
expect(lexicon._WidthHeight).toBe('Width');
|
||||
expect(lexicon._leftTop).toBe('left');
|
||||
expect(lexicon._LeftTop).toBe('Left');
|
||||
expect(lexicon._xy).toBe('x');
|
||||
expect(lexicon._XY).toBe('X');
|
||||
expect(lexicon._wh).toBe('w');
|
||||
expect(lexicon._lt).toBe('l');
|
||||
});
|
||||
});
|
||||
+3
-3
@@ -44,7 +44,7 @@ let bUpdateCount = 0;
|
||||
let cUpdateCount = 0;
|
||||
|
||||
const rootInstance = OverlayScrollbars(
|
||||
{ target: targetRoot!, padding: true },
|
||||
{ target: targetRoot!, elements: { padding: true } },
|
||||
{},
|
||||
{
|
||||
initialized() {
|
||||
@@ -65,7 +65,7 @@ const rootInstance = OverlayScrollbars(
|
||||
}
|
||||
);
|
||||
const aInstance = OverlayScrollbars(
|
||||
{ target: targetA!, content: true },
|
||||
{ target: targetA!, elements: { content: true } },
|
||||
{},
|
||||
{
|
||||
initialized() {
|
||||
@@ -107,7 +107,7 @@ const bInstance = OverlayScrollbars(
|
||||
}
|
||||
);
|
||||
OverlayScrollbars(
|
||||
{ target: targetC!, viewport: targetC! },
|
||||
{ target: targetC!, elements: { viewport: targetC! } },
|
||||
{},
|
||||
{
|
||||
initialized() {
|
||||
|
||||
+26
-53
@@ -70,7 +70,32 @@ declare const sizeObserverPlugin: Plugin<SizeObserverPluginInstance>;
|
||||
|
||||
declare type StaticInitialization = HTMLElement | false | null;
|
||||
declare type DynamicInitialization = HTMLElement | boolean | null;
|
||||
declare type Initialization = StructureInitialization & ScrollbarsInitialization & {
|
||||
/**
|
||||
* Static elements are elements which MUST be present in the final DOM.
|
||||
* With false, null or undefined the element will be generated, otherwise the specified element is taken.
|
||||
*/
|
||||
declare type StaticInitializationElement<Args extends any[]> = ((...args: Args) => StaticInitialization) | StaticInitialization;
|
||||
/**
|
||||
* Dynamic element are elements which CAN be present in the final DOM.
|
||||
* If its a element the element will be taken as the repsective element.
|
||||
* With true the element will be generated.
|
||||
* With false, null or undefined the element won't be generated and wont be in the DOM.
|
||||
*/
|
||||
declare type DynamicInitializationElement<Args extends any[]> = ((...args: Args) => DynamicInitialization) | DynamicInitialization;
|
||||
declare type Initialization = {
|
||||
elements: {
|
||||
host: StaticInitializationElement<[target: InitializationTargetElement]>;
|
||||
viewport: StaticInitializationElement<[target: InitializationTargetElement]>;
|
||||
padding: DynamicInitializationElement<[target: InitializationTargetElement]>;
|
||||
content: DynamicInitializationElement<[target: InitializationTargetElement]>;
|
||||
};
|
||||
scrollbars: {
|
||||
slot: DynamicInitializationElement<[
|
||||
target: InitializationTargetElement,
|
||||
host: HTMLElement,
|
||||
viewport: HTMLElement
|
||||
]>;
|
||||
};
|
||||
cancel: {
|
||||
nativeScrollbarsOverlaid: boolean;
|
||||
body: boolean | null;
|
||||
@@ -81,35 +106,6 @@ declare type InitializationTargetObject = DeepPartial<Initialization> & {
|
||||
target: InitializationTargetElement;
|
||||
};
|
||||
declare type InitializationTarget = InitializationTargetElement | InitializationTargetObject;
|
||||
/**
|
||||
* Static elements MUST be present.
|
||||
* With false, null or undefined the element will be generated, otherwise the specified element is taken.
|
||||
*/
|
||||
declare type StaticInitializationElement<Args extends any[]> = ((...args: Args) => StaticInitialization) | StaticInitialization;
|
||||
/**
|
||||
* Dynamic element CAN be present.
|
||||
* If its a element the element will be taken as the repsective element.
|
||||
* With true the element will be generated.
|
||||
* With false, null or undefined the element won't be generated.
|
||||
*/
|
||||
declare type DynamicInitializationElement<Args extends any[]> = ((...args: Args) => DynamicInitialization) | DynamicInitialization;
|
||||
|
||||
declare type ScrollbarsDynamicInitializationElement = DynamicInitializationElement<[
|
||||
target: InitializationTargetElement,
|
||||
host: HTMLElement,
|
||||
viewport: HTMLElement
|
||||
]>;
|
||||
/**
|
||||
* Object for special initialization.
|
||||
*
|
||||
* If element is provided, the provided element takes all its responsibilities.
|
||||
* DOM hierarchy isn't checked in this case, its assumed that hieararchy is correct in such a case.
|
||||
*
|
||||
* Null or Undefined means that the environment initialization strategy is used.
|
||||
*/
|
||||
interface ScrollbarsInitialization {
|
||||
scrollbarsSlot: ScrollbarsDynamicInitializationElement;
|
||||
}
|
||||
|
||||
interface StructureSetupState {
|
||||
_padding: TRBL;
|
||||
@@ -123,29 +119,6 @@ interface StructureSetupState {
|
||||
_directionIsRTL: boolean;
|
||||
}
|
||||
|
||||
declare type StructureStaticInitializationElement = StaticInitializationElement<[
|
||||
target: InitializationTargetElement
|
||||
]>;
|
||||
declare type StructureDynamicInitializationElement = DynamicInitializationElement<[
|
||||
target: InitializationTargetElement
|
||||
]>;
|
||||
/**
|
||||
* Object for special initialization.
|
||||
*
|
||||
* Target is always required, if element is not provided or undefined it will be generated.
|
||||
*
|
||||
* If element is provided, the provided element takes all its responsibilities.
|
||||
* DOM hierarchy isn't checked in this case, its assumed that hieararchy is correct in such a case.
|
||||
*
|
||||
* undefined means that the default initialization strategy is used.
|
||||
*/
|
||||
interface StructureInitialization {
|
||||
host: StructureStaticInitializationElement;
|
||||
viewport: StructureStaticInitializationElement;
|
||||
padding: StructureDynamicInitializationElement;
|
||||
content: StructureDynamicInitializationElement;
|
||||
}
|
||||
|
||||
interface ViewportOverflowState {
|
||||
_scrollbarsHideOffset: XY<number>;
|
||||
_scrollbarsHideOffsetArrange: XY<boolean>;
|
||||
|
||||
Reference in New Issue
Block a user