Skip to content

Commit

Permalink
Latest
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Jan 24, 2025
1 parent b80699d commit b9bf8cb
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 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.4] 2025-01-24

### Fixed

- Fix scale correction for CSS variables.

## [12.0.3] 2025-01-23

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/framer-motion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"bundlesize": [
{
"path": "./dist/size-rollup-motion.js",
"maxSize": "34.7 kB"
"maxSize": "34.75 kB"
},
{
"path": "./dist/size-rollup-m.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/framer-motion/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import alias from "@rollup/plugin-alias"
import resolve from "@rollup/plugin-node-resolve"
import { terser } from "rollup-plugin-terser"
import replace from "@rollup/plugin-replace"
import dts from "rollup-plugin-dts"
import alias from "@rollup/plugin-alias"
import path from "node:path"
import dts from "rollup-plugin-dts"
import preserveDirectives from "rollup-plugin-preserve-directives"
import { terser } from "rollup-plugin-terser"
import { fileURLToPath } from 'url'
import pkg from "./package.json" with { type: "json"}
import pkg from "./package.json" with { type: "json" }
import tsconfig from "./tsconfig.json" with { type: "json" }
import preserveDirectives from "rollup-plugin-preserve-directives";

const config = {
input: "lib/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ export function createProjectionNode<I>({
for (const key in scaleCorrectors) {
if (valuesToRender[key] === undefined) continue

const { correct, applyTo } = scaleCorrectors[key]
const { correct, applyTo, isCSSVariable } = scaleCorrectors[key]

/**
* Only apply scale correction to the value if we have an
Expand All @@ -1967,7 +1967,16 @@ export function createProjectionNode<I>({
styles[applyTo[i]] = corrected
}
} else {
styles[key] = corrected
// If this is a CSS variable, set it directly on the instance.
// Replacing this function from creating styles to setting them
// would be a good place to remove per frame object creation
if (isCSSVariable) {
;(
this.instance as unknown as HTMLElement
).style.setProperty(key, corrected as string)
} else {
styles[key] = corrected
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { isCSSVariableName } from "../../render/dom/utils/is-css-variable"
import { ScaleCorrectorMap } from "./types"

export const scaleCorrectors: ScaleCorrectorMap = {}

export function addScaleCorrector(correctors: ScaleCorrectorMap) {
Object.assign(scaleCorrectors, correctors)
for (const key in correctors) {
scaleCorrectors[key] = correctors[key]
if (isCSSVariableName(key)) {
scaleCorrectors[key].isCSSVariable = true
}
}
}
1 change: 1 addition & 0 deletions packages/framer-motion/src/projection/styles/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type ScaleCorrector = (
export interface ScaleCorrectorDefinition {
correct: ScaleCorrector
applyTo?: string[]
isCSSVariable?: boolean
}

export interface ScaleCorrectorMap {
Expand Down

0 comments on commit b9bf8cb

Please sign in to comment.