Disable Animations processing when Visual's not visible redux by jmacato · Pull Request #20820 · AvaloniaUI/Avalonia (original) (raw)
Pull request overview
This PR aims to stop spending time advancing keyframe animations when the target Visual isn’t effectively visible, and to end animations when a visual is detached from the visual tree.
Changes:
- Update
AnimationInstance<T>to pause the animation clock whenVisual.IsEffectivelyVisibleisfalse, and complete the animation when the visual detaches. - Extend unit tests to cover pausing/resuming on visibility changes (including nested visibility) and completion on visual-tree detach.
- Update the test
IClockimplementation to support multiple subscribers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/Avalonia.Base.UnitTests/Animation/TestClock.cs | Switches to multi-subscriber clock to support additional clock subscriptions introduced by animation visibility monitoring. |
| tests/Avalonia.Base.UnitTests/Animation/AnimationIterationTests.cs | Adds tests for pausing on IsEffectivelyVisible == false and completing on detach from visual tree. |
| src/Avalonia.Base/Animation/Animators/TransformAnimator.cs | Refactors transform-property animation application to use a subject/binding approach. |
| src/Avalonia.Base/Animation/AnimationInstance`1.cs | Adds visibility-based pause/resume and detach-based completion behavior for animations targeting Visuals. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.