@payfit/unity-components
Version:
33 lines (32 loc) • 789 B
JavaScript
//#region src/utils/scroll-detection.ts
function e(e, t = "size") {
let n = e.scrollHeight > e.clientHeight, r = e.scrollWidth > e.clientWidth, i = window.getComputedStyle(e), a = i.overflowY, o = i.overflowX, s = i.overflow, c = a === "scroll" || a === "auto" || s === "scroll" || s === "auto", l = o === "scroll" || o === "auto" || s === "scroll" || s === "auto", u, d;
switch (t) {
case "size":
u = n, d = r;
break;
case "style":
u = c, d = l;
break;
case "both":
u = n && c, d = r && l;
break;
}
return {
hasVerticalScroll: u,
hasHorizontalScroll: d,
hasAnyScroll: u || d,
detectionMethod: {
size: {
vertical: n,
horizontal: r
},
style: {
vertical: c,
horizontal: l
}
}
};
}
//#endregion
export { e as detectScroll };