tdesign-mobile-vue
Version:
tdesign-mobile-vue
45 lines (42 loc) • 1.24 kB
JavaScript
/**
* tdesign v1.7.0
* (c) 2024 TDesign Group
* @license MIT
*/
var findRelativeContainer = function findRelativeContainer(dom) {
var node = dom;
while (node && node !== document.body) {
var _getComputedStyle = getComputedStyle(node),
transform = _getComputedStyle.transform;
if (!/matrix\([\d,\s]+\)/.test(transform)) {
node = node.parentNode;
continue;
}
return node;
}
return null;
};
var findRelativeRect = function findRelativeRect(dom) {
var container = findRelativeContainer(dom);
var containerRect = container ? container.getBoundingClientRect() : {
top: 0,
left: 0
};
var _dom$getBoundingClien = dom.getBoundingClientRect(),
top = _dom$getBoundingClien.top,
left = _dom$getBoundingClien.left,
bottom = _dom$getBoundingClien.bottom,
right = _dom$getBoundingClien.right,
width = _dom$getBoundingClien.width,
height = _dom$getBoundingClien.height;
return {
top: top - containerRect.top,
bottom: bottom - containerRect.top,
left: left - containerRect.left,
right: right - containerRect.left,
width: width,
height: height
};
};
export { findRelativeContainer, findRelativeRect };
//# sourceMappingURL=dom-utils.js.map