ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
67 lines (66 loc) • 2.46 kB
JavaScript
import f from "../../_util/getScrollBarSize.mjs";
import a from "../../_util/setStyle.mjs";
let n = [];
const h = "ant-scrolling-effect", r = new RegExp(`${h}`, "g");
let m = 0;
const l = /* @__PURE__ */ new Map();
class N {
constructor(d) {
this.getContainer = () => {
var i;
return (i = this.options) == null ? void 0 : i.container;
}, this.reLock = (i) => {
const e = n.find(({ target: c }) => c === this.lockTarget);
e && this.unLock(), this.options = i, e && (e.options = i, this.lock());
}, this.lock = () => {
var s;
if (n.some(({ target: t }) => t === this.lockTarget))
return;
if (n.some(({ options: t }) => {
var o;
return (t == null ? void 0 : t.container) === ((o = this.options) == null ? void 0 : o.container);
})) {
n = [...n, { target: this.lockTarget, options: this.options }];
return;
}
let i = 0;
const e = ((s = this.options) == null ? void 0 : s.container) || document.body;
(e === document.body && window.innerWidth - document.documentElement.clientWidth > 0 || e.scrollHeight > e.clientHeight) && (i = f());
const c = e.className;
if (n.filter(({ options: t }) => {
var o;
return (t == null ? void 0 : t.container) === ((o = this.options) == null ? void 0 : o.container);
}).length === 0 && l.set(
e,
a(
{
width: i !== 0 ? `calc(100% - ${i}px)` : void 0,
overflow: "hidden",
overflowX: "hidden",
overflowY: "hidden"
},
{
element: e
}
)
), !r.test(c)) {
const t = `${c} ${h}`;
e.className = t.trim();
}
n = [...n, { target: this.lockTarget, options: this.options }];
}, this.unLock = () => {
var s;
const i = n.find(({ target: t }) => t === this.lockTarget);
if (n = n.filter(({ target: t }) => t !== this.lockTarget), !i || n.some(({ options: t }) => {
var o;
return (t == null ? void 0 : t.container) === ((o = i.options) == null ? void 0 : o.container);
}))
return;
const e = ((s = this.options) == null ? void 0 : s.container) || document.body, c = e.className;
r.test(c) && (a(l.get(e), { element: e }), l.delete(e), e.className = e.className.replace(r, "").trim());
}, this.lockTarget = m++, this.options = d;
}
}
export {
N as default
};