Files
QingLong/WebRoot/html/cdn/es/utils/scrollbar-width.mjs

30 lines
911 B
JavaScript
Raw Permalink Normal View History

2025-08-15 09:13:13 +08:00
import { isClient } from '@vueuse/core';
let scrollBarWidth;
function scrollbarWidth() {
var _a;
if (!isClient)
return 0;
if (scrollBarWidth !== void 0)
return scrollBarWidth;
const outer = document.createElement("div");
outer.className = "el-scrollbar__wrap";
outer.style.visibility = "hidden";
outer.style.width = "100px";
outer.style.position = "absolute";
outer.style.top = "-9999px";
document.body.appendChild(outer);
const widthNoScroll = outer.offsetWidth;
outer.style.overflow = "scroll";
const inner = document.createElement("div");
inner.style.width = "100%";
outer.appendChild(inner);
const widthWithScroll = inner.offsetWidth;
(_a = outer.parentNode) == null ? void 0 : _a.removeChild(outer);
scrollBarWidth = widthNoScroll - widthWithScroll;
return scrollBarWidth;
}
export { scrollbarWidth as default };
//# sourceMappingURL=scrollbar-width.mjs.map