18 lines
715 B
JavaScript
18 lines
715 B
JavaScript
|
import { convertBoundingBoxToBox, transformBoxPoints } from '../geometry/conversion.mjs';
|
||
|
import { translateAxis } from '../geometry/delta-apply.mjs';
|
||
|
|
||
|
function measureViewportBox(instance, transformPoint) {
|
||
|
return convertBoundingBoxToBox(transformBoxPoints(instance.getBoundingClientRect(), transformPoint));
|
||
|
}
|
||
|
function measurePageBox(element, rootProjectionNode, transformPagePoint) {
|
||
|
const viewportBox = measureViewportBox(element, transformPagePoint);
|
||
|
const { scroll } = rootProjectionNode;
|
||
|
if (scroll) {
|
||
|
translateAxis(viewportBox.x, scroll.offset.x);
|
||
|
translateAxis(viewportBox.y, scroll.offset.y);
|
||
|
}
|
||
|
return viewportBox;
|
||
|
}
|
||
|
|
||
|
export { measurePageBox, measureViewportBox };
|