Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Crossfade animation causes other animations to have hidden elements #14832

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

mjblacker
Copy link
Contributor

What does the pull request do?

Fix for CrossFade animation overwriting opacity causing elements to not show if you change the transition style (eg. PageSlide or none)

What is the current behavior?

When switching transition types on a control (EG. TransitioningContentControl) the opacity change is not reversed. This causes content to not show on other transition types.

This can be tested using the Catalog samples TransitioningContentControl.
Use the cross fade transition and move to another element in the control, then change to none and when transitioning some elements are hidden.

What is the updated/expected behavior with this PR?

Elements will maintain their existing opacity after a transition using CrossFade.

This can be tested using the Catalog samples TransitioningContentControl.
Use the cross fade transition and move to another element in the control, then change to none and when transitioning, elements should show as expected.

How was the solution implemented (if it's not obvious)?

Remove the opacity changes on the to/from Visual components and supporting code as the transition keyframes will take care of the opacity.

Fixed issues

Fixes #14054

@mjblacker
Copy link
Contributor Author

@dotnet-policy-service agree


if (from != null)
{
from.Opacity = 0f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to replace from.Opacity with the same:

disposables.Add(from.SetValue(Visual.OpacityProperty, 0, Data.BindingPriority.Animation)!)

Which should be reverted later, when disposables are disposed. But either way, your PR looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

This was my original solution but realised it could be simplified and assumed removing the disposables would be more performant.

@maxkatz6 maxkatz6 enabled auto-merge March 6, 2024 03:54
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0045736-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 6, 2024
Merged via the queue into AvaloniaUI:master with commit c5a13d8 Mar 6, 2024
6 checks passed
@mjblacker mjblacker deleted the bugfix/crossfade-animation branch March 6, 2024 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TransitioningContentControl] CrossFade Transaction Breck other Transation
3 participants