UNPKG

svelte-motion

Version:

Svelte animation library based on the React library framer-motion.

22 lines (19 loc) 775 B
/** based on framer-motion@4.0.3, Copyright (c) 2018 Framer B.V. */ import { convertBoundingBoxToAxisBox, transformBoundingBox } from '../../../utils/geometry/index.js'; /** * Measure and return the element bounding box. * * We convert the box into an AxisBox2D to make it easier to work with each axis * individually and programmatically. * * This function optionally accepts a transformPagePoint function which allows us to compensate * for, for instance, measuring the element within a scaled plane like a Framer devivce preview component. */ function getBoundingBox(element, transformPagePoint) { var box = element.getBoundingClientRect(); return convertBoundingBoxToAxisBox(transformBoundingBox(box, transformPagePoint)); } export { getBoundingBox };