34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
//#region node_modules/vuetify/lib/util/getScrollParent.js
|
|
function getScrollParent(el, includeHidden = false) {
|
|
while (el) {
|
|
if (includeHidden ? isPotentiallyScrollable(el) : hasScrollbar(el)) return el;
|
|
el = el.parentElement;
|
|
}
|
|
return document.scrollingElement;
|
|
}
|
|
function getScrollParents(el, stopAt) {
|
|
const elements = [];
|
|
if (stopAt && el && !stopAt.contains(el)) return elements;
|
|
while (el) {
|
|
if (hasScrollbar(el)) elements.push(el);
|
|
if (el === stopAt) break;
|
|
el = el.parentElement;
|
|
}
|
|
return elements;
|
|
}
|
|
function hasScrollbar(el) {
|
|
if (!el || el.nodeType !== Node.ELEMENT_NODE) return false;
|
|
const style = window.getComputedStyle(el);
|
|
const hasVerticalScrollbar = style.overflowY === "scroll" || style.overflowY === "auto" && el.scrollHeight > el.clientHeight;
|
|
const hasHorizontalScrollbar = style.overflowX === "scroll" || style.overflowX === "auto" && el.scrollWidth > el.clientWidth;
|
|
return hasVerticalScrollbar || hasHorizontalScrollbar;
|
|
}
|
|
function isPotentiallyScrollable(el) {
|
|
if (!el || el.nodeType !== Node.ELEMENT_NODE) return false;
|
|
const style = window.getComputedStyle(el);
|
|
return ["scroll", "auto"].includes(style.overflowY);
|
|
}
|
|
//#endregion
|
|
export { getScrollParents as n, hasScrollbar as r, getScrollParent as t };
|
|
|
|
//# sourceMappingURL=getScrollParent-DuXs8SPu.js.map
|