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

Fixed incorrect default easing for XAML animation types #4311

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected INormalizedKeyFrameAnimationBuilder<TKeyFrame> AppendToBuilder(INormal

if (from is not null)
{
builder.KeyFrame(0.0, from.Value, default, default);
builder.KeyFrame(0.0, from.Value);
}

return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public CompositionAnimation GetAnimation(UIElement element, out string? target)

if (from is not null)
{
builder.KeyFrame(0.0, from.Value, default, default);
builder.KeyFrame(0.0, from.Value, DefaultEasingType, DefaultEasingMode);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we pass the easing modes here but not in the other case?

(Also, why do we use the defaults here vs. checking for the overrides in the other cases?) If these distinctions are important should we add comments about it somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's becase the other case with no easing type/mode is calling INormalizedKeyFrameAnimationBuilder<TKeyFrame>.KeyFrame, which indicates the default easing values in its public API in the interface, so we can just omit those parameters and the compiler will insert them for us like it does normally for optional parameters with default values. Here instead we're calling NormalizedKeyFrameAnimationBuilder<T>.KeyFrame (on the concrete type, not the interface), which doesn't define the default values for those parameters (as it's an internal API only exposed publicly through that interface method, which inherits those from the interface itself). At the end of the day it's the same, really, it's just slightly different due to the language rules here. Does that make sense? 😄

As in:

IFoo i = new Foo();

i.Bar(); // Ok, passes 42

Foo c = new Foo();

c.Bar(); // Fails to build
c.Bar(42); // This is fine

interface IFoo
{
    void Bar(int x = 42);
}

class Foo : IFoo
{
    public void Bar(int x) { }
}

}

foreach (var keyFrame in KeyFrames)
Expand Down