@qntm-code/utils
Version:
A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.
21 lines (20 loc) • 619 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPositionedParent = void 0;
/**
* Gets the first parent element with a relative or absolute position
*/
function getPositionedParent(element) {
const parent = element.parentElement;
if (parent) {
const style = window.getComputedStyle(parent);
if (['relative', 'absolute'].includes(style.position)) {
return parent;
}
else {
return getPositionedParent(parent);
}
}
return document.documentElement;
}
exports.getPositionedParent = getPositionedParent;