feat(mix): add reverse animation config for style exit transitions#940
Open
tilucasoli wants to merge 1 commit into
Open
feat(mix): add reverse animation config for style exit transitions#940tilucasoli wants to merge 1 commit into
tilucasoli wants to merge 1 commit into
Conversation
Add an optional `reverse` parameter to `animate` so a variant style can own
both its enter and exit transition configs:
BoxStyler()
.animate(baseAnimation)
.onHovered(BoxStyler().scale(1.02).animate(hoverIn, reverse: hoverOut));
When a style becomes active, Mix uses the target style's forward config; when
it is no longer active, Mix uses the leaving style's reverse config. The reverse
config is only used when the old and new animation metadata are distinct, so an
inherited base reversible config is not mistaken for an exit animation.
- Add `ReversibleAnimationConfig` wrapping forward + reverse configs.
- `StyleAnimationBuilder` selects the effective transition config from old/new
metadata and compares against the active driver kind (so forward and reverse
may use different driver kinds).
- Generated `animate` methods and static factories accept `{AnimationConfig? reverse}`
and wrap only when reverse is provided.
Closes #929
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Closes #929.
Adds an optional
reverseparameter toanimateso a variant style can own both its enter and exit transition configs, instead of splitting an interaction's enter/exit timing across two styles:When the hover style becomes active, Mix uses
hoverIn; when it is no longer active, Mix useshoverOut. With noreversedeclared, behavior is unchanged.Semantics
reverseis an exit transition config; it does not mean callingAnimationController.reverse().Changes
Core (
packages/mix)animation/animation_config.dart— newReversibleAnimationConfigwrappingforward+reverse.animation/style_animation_builder.dart— selects the effective transition config from old/new metadata (_transitionConfig/_forwardOf/_reverseOf) and tracks the active driver's config kind, so forward and reverse may use different driver kinds without type errors.style/mixins/animation_style_mixin.dart— abstractanimategains{AnimationConfig? reverse}.Generator (
packages/mix_generator)animateinstance methods and static factories accept{AnimationConfig? reverse}and wrap inReversibleAnimationConfigonly whenreverseis provided.*_spec.g.dartfiles.Acceptance criteria
.animate(config)calls continue to compile..animate(config, reverse: reverseConfig).Styler.animate(config, reverse: reverseConfig).Test plan
mix: animation + hover suites green (test/src/animation/,test/src/core/style_builder_hover_test.dart); full suite 2756 passing.mix_generator: full suite (257) passing; updated signature assertions + addedReversibleAnimationConfigto the mock mix stub.ReversibleAnimationConfigequality/props,.animate(reverse:)wrapping (instance + static factory), and hover enter/exit + inherited-config widget tests.🤖 Generated with Claude Code