fix: support numeric values for CSS logical properties in useTransform#3430
Conversation
|
Great PR! While you're at it, would it be possible to add support for the Since they share the same shorthand logic as As-isCurrent Issue Currently, when using CSS variables within these shorthand properties, they are not parsed correctly, as shown in the screenshots below 2025-12-28.3.22.24.movTo-beExpected Behavior By adding these to px-values.ts and number.ts, Framer Motion should be able to parse them correctly 2025-12-28.3.24.57.movI also noticed that #3413 is very similar to this. Since you're already "under the hood" and working on this part of the code, maybe we could bundle them together? It’d be awesome to have all these layout shorthands supported at once—it would make the CSS variable support so much more robust! What do you think about tossing these into your PR? |
Good catch! I agree this should be supported as well. Since the Thanks for sharing the examples! |
80f1ec7 to
ba2f82c
Compare
Issue
Summary
useTransformdid not correctly convert numeric values to pixel units when used with CSS logical properties (e.g.paddingBlock,paddingInline,marginBlock,marginInline), causing styles to update incorrectly.This PR fixes the missing px conversion so CSS logical properties are handled consistently with other CSS properties.
Root Cause
CSS logical properties were missing from the internal px conversion mappings (
numberValueTypesandpxValues).As a result, numeric values returned from
useTransformwere written to the DOM without units and treated as invalid CSS.Because CSS allows unitless
0, intermediate values were ignored, making updates appear to jump from0to the final value.Solution
CSS logical properties were added to both px conversion paths.
Updated files
packages/motion-dom/src/value/types/maps/number.tspackages/motion-dom/src/animation/waapi/utils/px-values.tsNumeric values returned from
useTransformare now converted to"px"before being applied to the DOM.As-is / To-be
As-is
px2025-12-27.11.27.31.mov
To-be
2025-12-27.11.31.44.mov