antdv-eoi
Version:
An enterprise-class UI design language and Vue-based implementation
51 lines (38 loc) • 1.03 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var style = function style(element, prop) {
var styleVal = '';
if (typeof getComputedStyle !== 'undefined') {
styleVal = window.getComputedStyle(element, null).getPropertyValue(prop);
} else {
styleVal = element.style[prop];
}
return styleVal;
};
var overflow = function overflow(element) {
return style(element, 'overflow') + style(element, 'overflow-y') + style(element, 'overflow-x');
};
var scrollParent = function scrollParent(element) {
if (!(element instanceof window.HTMLElement)) {
return window;
}
var parent = element;
while (parent) {
if (parent === document.body || parent === document.documentElement) {
break;
}
if (!parent.parentNode) {
break;
}
if (/(scroll|auto)/.test(overflow(parent))) {
return parent;
}
parent = parent.parentNode;
}
return window;
};
var _default = scrollParent;
exports.default = _default;
;