Skip to content

Commit

Permalink
Latest
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Feb 3, 2025
1 parent 4855269 commit f0172c9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Motion adheres to [Semantic Versioning](http://semver.org/).

Undocumented APIs should be considered internal and may change without warning.

## [12.0.11] 2025-02-03

### Fixed

- Moving `updateSVGDimensions` to its own file to help with tree-shaking.

## [12.0.10] 2025-02-03

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/framer-motion/src/render/svg/SVGVisualElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { getDefaultValueType } from "../dom/value-types/defaults"
import { transformProps } from "../html/utils/keys-transform"
import { ResolvedValues } from "../types"
import { VisualElement } from "../VisualElement"
import { updateSVGDimensions } from "./config-motion"
import { SVGRenderState } from "./types"
import { buildSVGAttrs } from "./utils/build-attrs"
import { camelCaseAttributes } from "./utils/camel-case-attrs"
import { isSVGTag } from "./utils/is-svg-tag"
import { updateSVGDimensions } from "./utils/measure"
import { renderSVG } from "./utils/render"
import { scrapeMotionValuesFromProps } from "./utils/scrape-motion-values"

Expand Down
21 changes: 1 addition & 20 deletions packages/framer-motion/src/render/svg/config-motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,10 @@ import { SVGRenderState } from "./types"
import { buildSVGAttrs } from "./utils/build-attrs"
import { createSvgRenderState } from "./utils/create-render-state"
import { isSVGTag } from "./utils/is-svg-tag"
import { updateSVGDimensions } from "./utils/measure"
import { renderSVG } from "./utils/render"
import { scrapeMotionValuesFromProps as scrapeSVGProps } from "./utils/scrape-motion-values"

export function updateSVGDimensions(
instance: SVGElement,
renderState: SVGRenderState
) {
try {
renderState.dimensions =
typeof (instance as SVGGraphicsElement).getBBox === "function"
? (instance as SVGGraphicsElement).getBBox()
: (instance.getBoundingClientRect() as DOMRect)
} catch (e) {
// Most likely trying to measure an unrendered element under Firefox
renderState.dimensions = {
x: 0,
y: 0,
width: 0,
height: 0,
}
}
}

const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"]

export const svgMotionConfig: Partial<
Expand Down
20 changes: 20 additions & 0 deletions packages/framer-motion/src/render/svg/utils/measure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { SVGRenderState } from "../types"
export function updateSVGDimensions(
instance: SVGElement,
renderState: SVGRenderState
) {
try {
renderState.dimensions =
typeof (instance as SVGGraphicsElement).getBBox === "function"
? (instance as SVGGraphicsElement).getBBox()
: (instance.getBoundingClientRect() as DOMRect)
} catch (e) {
// Most likely trying to measure an unrendered element under Firefox
renderState.dimensions = {
x: 0,
y: 0,
width: 0,
height: 0,
}
}
}

0 comments on commit f0172c9

Please sign in to comment.