securityos/node_modules/framer-motion/dist/es/projection/utils/measure.mjs

18 lines
715 B
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
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 };