mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
14 lines
346 B
TypeScript
14 lines
346 B
TypeScript
import { isElement } from '@alilc/lowcode-utils';
|
|
|
|
// a range for test TextNode clientRect
|
|
const cycleRange = document.createRange();
|
|
|
|
export function getClientRects(node: Element | Text) {
|
|
if (isElement(node)) {
|
|
return [node.getBoundingClientRect()];
|
|
}
|
|
|
|
cycleRange.selectNode(node);
|
|
return Array.from(cycleRange.getClientRects());
|
|
}
|