Collapse ElementState into a thin effect adapter - #3822
Closed
mattgperry wants to merge 1 commit into
Closed
mattgperry wants to merge 1 commit into
mattgperry wants to merge 1 commit into
Conversation
animate()'s element path had grown an ElementState class that re-implemented getValue-with-default, addValue and read normalisation on top of styleEffect. Move each concern to where it belongs so the class becomes a five-line binding of (effect, element) to the resolver's VisualElement-shaped interface: - The DOM keyframe resolver uses its own motionValue for measurement instead of asking the element to get-or-create it; getValue(key) is now only a lookup of the other transform keys it zeroes, i.e. effect.get. - Origin normalisation (numeric strings, animatable "none") happens in KeyframesResolver on whatever the raw read returns, rather than in each readValue implementation. - Effects expose flush(subject) so the resolver can write pending values before measuring. - readStyleValue reports an unreadable style as 0, as VisualElement does. - animateElement and animateEffectSubject share one loop (animateValues), differing only in how a value is fetched or created. Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Author
|
Folded into #3815. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #3819 (which is stacked on #3815).
Summary
animate()'s element path had grown anElementStateclass re-implementinggetValue-with-default,addValueand read normalisation on top ofstyleEffect. This moves each concern to where it belongs, so what's left is a five-line binding of(effect, element)to the resolver'sVisualElement-shaped interface, holding no state of its own.DOMKeyframesResolveralready holdsthis.motionValue, which is the value it was fetching viaelement.getValue(name, measureKeyframe).getValue(key)is now only a lookup of the other transform keys it zeroes for measurement, i.e.effect.get. The create-with-default overload is gone from the interface.KeyframesResolver. Numeric strings → numbers and non-animatable"none"→ animatable zero are applied once to whatever the raw read returns, instead of being duplicated in everyreadValueimplementation.readValueon the element side is now justeffect.read. (VisualElement.readValuekeeps its copy for now because it also feedssetBaseTarget; the second pass is a no-op on already-normalised values.)flush(subject)so the resolver can write pending values before measuring.render()iseffect.flush.readStyleValuereports an unreadable style as0, matchingVisualElement.readValueFromInstance— this was previously hidden in the adapter.animateElementandanimateEffectSubjectshareanimateValues(getValue, keyframes, transition, element?); they differ only in how a value is fetched or created (effect.get+ bind vsvisualElement.getValue(key, null)). The skip-when-already-at-target andtransitionEndhandling now apply to effect subjects too.What remains (
EffectSubject) exists because the resolver and WAAPI still speak to an object shaped like aVisualElement, andVisualElementis the other implementor. It goes when the resolver can take(effect, subject)directly, aftermotion.*moves ontostyleEffect.Size (gzip, vs #3819)
animatedom-animationdom-maxstyle-effectTest plan
yarn test— all packages greenanimate-unit-types,unit-conversion,animate-read-transform,animate-height-border-box,animate-filter-blur,waapi,waapi-svg,animate-style,animate-cancel,animate-reverse,waapi-interrupt-transform,animate-sequence-spring— all passingMade with Cursor