Add MotionValueState infrastructure for atomic DOM updates#3451
Add MotionValueState infrastructure for atomic DOM updates#3451mattgperry wants to merge 2 commits intomainfrom
Conversation
Introduce MotionValueState class hierarchy to enable per-value DOM rendering instead of rebuilding all styles every frame: - Add HTMLMotionValueState for atomic HTML style updates - Add SVGMotionValueState for atomic SVG attribute updates - Add createMotionValueState() abstract method to VisualElement - Implement state factories in HTML, SVG, Object, and State visual elements - Add forEach() and getStatic() methods to MotionValueState - Add prevValue tracking to prevent duplicate change callbacks The state infrastructure is in place but values are bound via bindToMotionValue to maintain backward-compatible onUpdate behavior. This prepares for future atomic update optimizations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review: MotionValueState InfrastructureThis is a well-architected refactoring that introduces a solid foundation for atomic DOM updates. The implementation is careful to maintain backward compatibility while setting up infrastructure for future optimizations. Here's my detailed feedback: 🎯 Architecture & DesignStrengths:
Concerns:
🐛 Potential Issues1. Memory Leak Risk in
|
Benchmark with 200 divs that measures the overhead difference between: - Phase 1: Animating x, y, scale, rotate, backgroundColor (baseline) - Phase 2: Animating only backgroundColor (tests transform rebuild overhead) In the current renderer, Phase 2 still rebuilds transform strings even though only backgroundColor is changing. With atomic updates, Phase 2 would only touch the backgroundColor style property. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request Review: Add MotionValueState infrastructure for atomic DOM updatesSummaryThis PR introduces a foundational infrastructure for per-value DOM rendering, preparing the codebase for atomic update optimizations. The implementation is well-architected and maintains backward compatibility while setting the stage for future performance improvements. Code Quality & Architecture ✅Strengths:
Architecture highlights:
Potential Issues & Concerns1. Memory Leak Risk in HTMLMotionValueState constructor
|
|
Closing for now as although interesting, not quite as large of an improvement for such a big change |
Summary
MotionValueStateclass hierarchy to enable per-value DOM rendering instead of rebuilding all styles every frameHTMLMotionValueStatefor atomic HTML style updates (transform, CSS variables, regular styles)SVGMotionValueStatefor atomic SVG attribute updatescreateMotionValueState()abstract method toVisualElementwith implementations in HTML, SVG, Object, and State visual elementsMotionValueStatewithforEach(),getStatic(), andprevValuetrackingTechnical Notes
The state infrastructure is in place but values are currently bound via
bindToMotionValueto maintain backward-compatibleonUpdatebehavior. This prepares the codebase for future atomic update optimizations where:transformMotionValueTest plan
🤖 Generated with Claude Code