vuesax-alpha
Version:
A Component Library for Vue 3
33 lines (28 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var dom = require('../../utils/dom.js');
function getTrueOffsetParent(element, polyfill) {
if (!dom.isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
return null;
}
if (polyfill) {
return polyfill(element);
}
return element.offsetParent;
}
function getOffsetParent(element, polyfill) {
const window = dom.getWindow(element);
if (!dom.isHTMLElement(element)) {
return window;
}
let offsetParent = getTrueOffsetParent(element, polyfill);
while (offsetParent && dom.isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
}
if (offsetParent && (dom.getNodeName(offsetParent) === "html" || dom.getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !dom.isContainingBlock(offsetParent))) {
return window;
}
return offsetParent || dom.getContainingBlock(element) || window;
}
exports.getOffsetParent = getOffsetParent;
//# sourceMappingURL=get-offset-parent.js.map