diff --git a/CHANGELOG.md b/CHANGELOG.md index 68ed119ef1..edcfbe4fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/dev/html/package.json b/dev/html/package.json index 016c9e83d2..77a85dc2cc 100644 --- a/dev/html/package.json +++ b/dev/html/package.json @@ -1,7 +1,7 @@ { "name": "html-env", "private": true, - "version": "12.0.10", + "version": "12.0.11", "type": "module", "scripts": { "dev": "vite", @@ -10,8 +10,8 @@ "preview": "vite preview" }, "dependencies": { - "framer-motion": "^12.0.10", - "motion": "^12.0.10", + "framer-motion": "^12.0.11", + "motion": "^12.0.11", "motion-dom": "^12.0.0" }, "devDependencies": { diff --git a/dev/next/package.json b/dev/next/package.json index e932fa5150..2154fd6a46 100644 --- a/dev/next/package.json +++ b/dev/next/package.json @@ -1,7 +1,7 @@ { "name": "next-env", "private": true, - "version": "12.0.10", + "version": "12.0.11", "type": "module", "scripts": { "dev": "next dev", @@ -9,7 +9,7 @@ "start": "next start" }, "dependencies": { - "motion": "^12.0.10", + "motion": "^12.0.11", "next": "14.x", "react": "^18.3.1", "react-dom": "^18.3.1" diff --git a/dev/react-19/package.json b/dev/react-19/package.json index 98c781ebac..21bbce9f14 100644 --- a/dev/react-19/package.json +++ b/dev/react-19/package.json @@ -1,7 +1,7 @@ { "name": "react-19-env", "private": true, - "version": "12.0.10", + "version": "12.0.11", "type": "module", "scripts": { "dev": "vite", @@ -11,7 +11,7 @@ "preview": "vite preview" }, "dependencies": { - "motion": "^12.0.10", + "motion": "^12.0.11", "react": "^19.0.0", "react-dom": "^19.0.0" }, diff --git a/dev/react/package.json b/dev/react/package.json index e061713833..5a03614823 100644 --- a/dev/react/package.json +++ b/dev/react/package.json @@ -1,7 +1,7 @@ { "name": "react-env", "private": true, - "version": "12.0.10", + "version": "12.0.11", "type": "module", "scripts": { "dev": "vite", @@ -11,7 +11,7 @@ "preview": "vite preview" }, "dependencies": { - "framer-motion": "^12.0.10", + "framer-motion": "^12.0.11", "react": "^18.3.1", "react-dom": "^18.3.1" }, diff --git a/lerna.json b/lerna.json index af9034a32f..75a58e0982 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "12.0.10", + "version": "12.0.11", "packages": [ "packages/*", "dev/*" diff --git a/packages/framer-motion-3d/package.json b/packages/framer-motion-3d/package.json index 6d64dc03e2..307e1916f1 100644 --- a/packages/framer-motion-3d/package.json +++ b/packages/framer-motion-3d/package.json @@ -1,6 +1,6 @@ { "name": "framer-motion-3d", - "version": "12.0.10", + "version": "12.0.11", "description": "A simple and powerful React animation library for @react-three/fiber", "main": "dist/cjs/index.js", "module": "dist/es/index.mjs", @@ -45,7 +45,7 @@ "postpublish": "git push --tags" }, "dependencies": { - "framer-motion": "^12.0.10", + "framer-motion": "^12.0.11", "react-merge-refs": "^2.0.1" }, "peerDependencies": { diff --git a/packages/framer-motion/package.json b/packages/framer-motion/package.json index ab5c676afb..c61df7dde2 100644 --- a/packages/framer-motion/package.json +++ b/packages/framer-motion/package.json @@ -1,6 +1,6 @@ { "name": "framer-motion", - "version": "12.0.10", + "version": "12.0.11", "description": "A simple and powerful JavaScript animation library", "main": "dist/cjs/index.js", "module": "dist/es/index.mjs", @@ -47,7 +47,7 @@ }, "./package.json": "./package.json" }, - "types": "dist/index.d.ts", + "types": "dist/types/index.d.ts", "author": "Matt Perry", "license": "MIT", "repository": "https://github.com/motiondivision/motion/", diff --git a/packages/framer-motion/src/motion/__tests__/types.test.tsx b/packages/framer-motion/src/motion/__tests__/types.test.tsx index adbe6e6a01..94e1abbde9 100644 --- a/packages/framer-motion/src/motion/__tests__/types.test.tsx +++ b/packages/framer-motion/src/motion/__tests__/types.test.tsx @@ -1,6 +1,5 @@ import { motion, useMotionValue } from "framer-motion" import * as clientMotion from "framer-motion/client" -import * as React from "react" import { render } from "../../../jest.setup" describe("accepts motion values into both motion components from both entry points", () => { diff --git a/packages/framer-motion/src/render/svg/SVGVisualElement.ts b/packages/framer-motion/src/render/svg/SVGVisualElement.ts index 19eac46ce6..1f0e91b3f3 100644 --- a/packages/framer-motion/src/render/svg/SVGVisualElement.ts +++ b/packages/framer-motion/src/render/svg/SVGVisualElement.ts @@ -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" diff --git a/packages/framer-motion/src/render/svg/config-motion.ts b/packages/framer-motion/src/render/svg/config-motion.ts index 2d48bdd83e..03d6cfd2f5 100644 --- a/packages/framer-motion/src/render/svg/config-motion.ts +++ b/packages/framer-motion/src/render/svg/config-motion.ts @@ -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< diff --git a/packages/framer-motion/src/render/svg/utils/measure.ts b/packages/framer-motion/src/render/svg/utils/measure.ts new file mode 100644 index 0000000000..d8214b18a3 --- /dev/null +++ b/packages/framer-motion/src/render/svg/utils/measure.ts @@ -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, + } + } +} diff --git a/packages/motion/package.json b/packages/motion/package.json index 1f411fa6e7..a469b7cf82 100644 --- a/packages/motion/package.json +++ b/packages/motion/package.json @@ -1,6 +1,6 @@ { "name": "motion", - "version": "12.0.10", + "version": "12.0.11", "description": "An animation library for JavaScript and React.", "main": "dist/cjs/index.js", "module": "dist/es/motion/lib/index.mjs", @@ -70,7 +70,7 @@ "postpublish": "git push --tags" }, "dependencies": { - "framer-motion": "^12.0.10", + "framer-motion": "^12.0.11", "tslib": "^2.4.0" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index df9106cd22..2961b749fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7015,7 +7015,7 @@ __metadata: "@react-three/fiber": 8.2.2 "@react-three/test-renderer": ^9.0.0 "@rollup/plugin-commonjs": ^22.0.1 - framer-motion: ^12.0.10 + framer-motion: ^12.0.11 react-merge-refs: ^2.0.1 three: ^0.137.0 peerDependencies: @@ -7026,7 +7026,7 @@ __metadata: languageName: unknown linkType: soft -"framer-motion@^12.0.10, framer-motion@workspace:packages/framer-motion": +"framer-motion@^12.0.11, framer-motion@workspace:packages/framer-motion": version: 0.0.0-use.local resolution: "framer-motion@workspace:packages/framer-motion" dependencies: @@ -7789,8 +7789,8 @@ __metadata: version: 0.0.0-use.local resolution: "html-env@workspace:dev/html" dependencies: - framer-motion: ^12.0.10 - motion: ^12.0.10 + framer-motion: ^12.0.11 + motion: ^12.0.11 motion-dom: ^12.0.0 vite: ^5.2.0 languageName: unknown @@ -10644,11 +10644,11 @@ __metadata: languageName: unknown linkType: soft -"motion@^12.0.10, motion@workspace:packages/motion": +"motion@^12.0.11, motion@workspace:packages/motion": version: 0.0.0-use.local resolution: "motion@workspace:packages/motion" dependencies: - framer-motion: ^12.0.10 + framer-motion: ^12.0.11 tslib: ^2.4.0 peerDependencies: "@emotion/is-prop-valid": "*" @@ -10765,7 +10765,7 @@ __metadata: version: 0.0.0-use.local resolution: "next-env@workspace:dev/next" dependencies: - motion: ^12.0.10 + motion: ^12.0.11 next: 14.x react: ^18.3.1 react-dom: ^18.3.1 @@ -12252,7 +12252,7 @@ __metadata: "@typescript-eslint/parser": ^7.2.0 "@vitejs/plugin-react-swc": ^3.5.0 eslint-plugin-react-refresh: ^0.4.6 - motion: ^12.0.10 + motion: ^12.0.11 react: ^19.0.0 react-dom: ^19.0.0 vite: ^5.2.0 @@ -12324,7 +12324,7 @@ __metadata: "@typescript-eslint/parser": ^7.2.0 "@vitejs/plugin-react-swc": ^3.5.0 eslint-plugin-react-refresh: ^0.4.6 - framer-motion: ^12.0.10 + framer-motion: ^12.0.11 react: ^18.3.1 react-dom: ^18.3.1 styled-components: ^6.1.11