UNPKG

@aplus-frontend/ui

Version:

38 lines (37 loc) 967 B
import { getScrollbarSize as i } from "../utils/index.mjs"; function d(o) { if (!o || o.nodeType !== Node.ELEMENT_NODE) return { x: !1, y: !1 }; const e = window.getComputedStyle(o), l = e.overflowX, t = e.overflowY, n = l === "scroll" || l === "auto", r = t === "scroll" || t === "auto", c = o.scrollWidth > o.clientWidth, s = o.scrollHeight > o.clientHeight; return { x: n && c, y: r && s }; } function f() { const o = `aplus-ui-locker-${Date.now()}`, { y: e } = d(document.body); if (!e) return; const l = i(); let t = document.querySelector(`style#${o}`); return t || (t = document.createElement("style"), t.id = o, t.innerHTML = ` html body { overflow-y: hidden; width: calc(100% - ${l || 15}px); } `, document.head.appendChild(t)), () => { t.remove(); }; } function a() { let o = 99; return () => ++o; } const y = a(); export { y as getMaskZIndex, f as lockScrollable };