motiondivision / motion

A modern animation library for React and JavaScript
https://motion.dev
MIT License
25.84k stars 849 forks source link

Optimise `transform` string #2747

Closed mattgperry closed 3 months ago

mattgperry commented 3 months ago

Currently, if any transform is non-default, all non-default transforms get included in the transform string:

{ x: 0 } => "none"
{ x: 0, scale: 1.2 } => "translateX(0px) scale(1.2)"

This PR changes it so these no-op transforms are excluded.

{ x: 0 } => "none"
{ x: 0, scale: 1.2 } => "scale(1.2)"

This results in up to 30% faster effects in the way we have it configured inside Framer (where transforms might be provided as MotionValues but always stay at default values).