File tree Expand file tree Collapse file tree 6 files changed +31
-9
lines changed Expand file tree Collapse file tree 6 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ Motion adheres to [Semantic Versioning](http://semver.org/).
4
4
5
5
Undocumented APIs should be considered internal and may change without warning.
6
6
7
+ ## [ 12.0.4] 2025-01-24
8
+
9
+ ### Fixed
10
+
11
+ - Fix scale correction for CSS variables.
12
+
7
13
## [ 12.0.3] 2025-01-23
8
14
9
15
### Fixed
Original file line number Diff line number Diff line change 110
110
"bundlesize" : [
111
111
{
112
112
"path" : " ./dist/size-rollup-motion.js" ,
113
- "maxSize" : " 34.7 kB"
113
+ "maxSize" : " 34.75 kB"
114
114
},
115
115
{
116
116
"path" : " ./dist/size-rollup-m.js" ,
Original file line number Diff line number Diff line change
1
+ import alias from "@rollup/plugin-alias"
1
2
import resolve from "@rollup/plugin-node-resolve"
2
- import { terser } from "rollup-plugin-terser"
3
3
import replace from "@rollup/plugin-replace"
4
- import dts from "rollup-plugin-dts"
5
- import alias from "@rollup/plugin-alias"
6
4
import path from "node:path"
5
+ import dts from "rollup-plugin-dts"
6
+ import preserveDirectives from "rollup-plugin-preserve-directives"
7
+ import { terser } from "rollup-plugin-terser"
7
8
import { fileURLToPath } from 'url'
8
- import pkg from "./package.json" with { type : "json" }
9
+ import pkg from "./package.json" with { type : "json" }
9
10
import tsconfig from "./tsconfig.json" with { type : "json" }
10
- import preserveDirectives from "rollup-plugin-preserve-directives" ;
11
11
12
12
const config = {
13
13
input : "lib/index.js" ,
Original file line number Diff line number Diff line change @@ -1948,7 +1948,7 @@ export function createProjectionNode<I>({
1948
1948
for ( const key in scaleCorrectors ) {
1949
1949
if ( valuesToRender [ key ] === undefined ) continue
1950
1950
1951
- const { correct, applyTo } = scaleCorrectors [ key ]
1951
+ const { correct, applyTo, isCSSVariable } = scaleCorrectors [ key ]
1952
1952
1953
1953
/**
1954
1954
* Only apply scale correction to the value if we have an
@@ -1967,7 +1967,16 @@ export function createProjectionNode<I>({
1967
1967
styles [ applyTo [ i ] ] = corrected
1968
1968
}
1969
1969
} else {
1970
- styles [ key ] = corrected
1970
+ // If this is a CSS variable, set it directly on the instance.
1971
+ // Replacing this function from creating styles to setting them
1972
+ // would be a good place to remove per frame object creation
1973
+ if ( isCSSVariable ) {
1974
+ ; (
1975
+ this . instance as unknown as HTMLElement
1976
+ ) . style . setProperty ( key , corrected as string )
1977
+ } else {
1978
+ styles [ key ] = corrected
1979
+ }
1971
1980
}
1972
1981
}
1973
1982
Original file line number Diff line number Diff line change
1
+ import { isCSSVariableName } from "../../render/dom/utils/is-css-variable"
1
2
import { ScaleCorrectorMap } from "./types"
2
3
3
4
export const scaleCorrectors : ScaleCorrectorMap = { }
4
5
5
6
export function addScaleCorrector ( correctors : ScaleCorrectorMap ) {
6
- Object . assign ( scaleCorrectors , correctors )
7
+ for ( const key in correctors ) {
8
+ scaleCorrectors [ key ] = correctors [ key ]
9
+ if ( isCSSVariableName ( key ) ) {
10
+ scaleCorrectors [ key ] . isCSSVariable = true
11
+ }
12
+ }
7
13
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export type ScaleCorrector = (
8
8
export interface ScaleCorrectorDefinition {
9
9
correct : ScaleCorrector
10
10
applyTo ?: string [ ]
11
+ isCSSVariable ?: boolean
11
12
}
12
13
13
14
export interface ScaleCorrectorMap {
You can’t perform that action at this time.
0 commit comments