Skip to content

Inconsistent/glitchy behavior for repeated explicit animations with starting value + delay #4306

Open
@Sergio0694

Description

@Sergio0694

Describe the bug

Using a XAML ScalarAnimation with a delay results in a weird snapping animation after the first time the animation is played. Running the same exact animation in C# using AnimationBuilder works fine instead. This issue is forcing us to write more animations in C# than we'd like in the Store client. We should investigate and fix this to ensure consistency between C#/XAML.

Steps to Reproduce

  • Can this be reproduced in the Sample App? (Either in a sample as-is or with new XAML pasted in the editor.) If so, please provide custom XAML or steps to reproduce. If not, let us know why it can't be reproduced (e.g. more complex setup, environment, dependencies, etc...)
<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
    xmlns:mediaactions="using:Microsoft.Xaml.Interactions.Media"
    xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
    xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
    xmlns:core="using:Microsoft.Xaml.Interactions.Core"
    mc:Ignorable="d">

  <Button
    Background="Gray"
    Width="200"
    Height="200"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"
    Content="🦙 Text">
    <ani:Explicit.Animations>
      <ani:AnimationSet x:Name="TestAnimation">
        <ani:ScalarAnimation
            Target="Translation.Y"
            From="96"
            To="0"
            Delay="0:0:1"
            Duration="0:0:0.6"/>
      </ani:AnimationSet>
    </ani:Explicit.Animations>

    <interactivity:Interaction.Behaviors>
      <interactions:EventTriggerBehavior EventName="Click">
        <behaviors:StartAnimationAction Animation="{Binding ElementName=TestAnimation}"/>
      </interactions:EventTriggerBehavior>
    </interactivity:Interaction.Behaviors>
  </Button>
</Page>

Note how the first time the animation is played it runs fine, but it-s glitchy after that.

Using C# works just fine instead:

AnimationBuilder.Create()
    .Translation(
        Axis.Y,
        from: 96,
        to: 0,
        delay: TimeSpan.FromMilliseconds(1000),
        duration: TimeSpan.FromMilliseconds(600))
    .Start((Button)sender);

Expected behavior

The XAML animation should play the exact same as the one declared using C#.

Screenshots

TrtkkqiLTU.mp4

Environment

NuGet Package(s): Microsoft.Toolkit.Uwp.UI.Animations/Behaviors 7.1.0

OS:

  • Windows 11 Enterprise 22000.194

App min and target version:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • May 2020 Update (19041)
  • Insider Build ({build_number})
  • 22000 SDK

Device form factor:

  • Desktop
  • Xbox
  • Surface Hub
  • IoT

Visual Studio version:

  • 2017 (15.{minor_version})
  • 2019 (16.4)
  • 2022 (17.{minor_version})

Additional context

Metadata

Metadata

Assignees

Labels

animations 🏮bug 🐛An unexpected issue that highlights incorrect behaviorexternal ⤴️Requires an update to an external dependency or due to code outside the Toolkit.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions