Skip to content

Commit

Permalink
Merge pull request #3046 from unoplatform/dev/djo/animation-fix
Browse files Browse the repository at this point in the history
fix(animation): [iOS] Fix InvalidCastException when app resumes while animation is active
  • Loading branch information
davidjohnoliver authored Apr 27, 2020
2 parents 7764769 + 32dba9c commit 9ec81eb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Animation;

namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media_Animation
{
[TestClass]
public class Given_DoubleAnimation
{
[TestMethod]
[RunsOnUIThread]
public void When_SeekAlignedToLastTick()
{
var target = new Border();
var doubleAnimation = new DoubleAnimation()
{
From = 50d,
To = 100d,
EnableDependentAnimation = true
};
Storyboard.SetTarget(doubleAnimation, target);
Storyboard.SetTargetProperty(doubleAnimation, "Height");
var sb = new Storyboard()
{
Children =
{
doubleAnimation
}
};

sb.Begin();
sb.SeekAlignedToLastTick(TimeSpan.FromMilliseconds(50));
}
}
}
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/Media/Animation/Timeline.animation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void Seek(TimeSpan offset)
public void SeekAlignedToLastTick(TimeSpan offset)
{
// Same as Seek
((ITimeline)this).Seek(offset);
Seek(offset);
}

public void SkipToFill()
Expand Down Expand Up @@ -296,7 +296,7 @@ private void Play()
// state. (The ideal would probably be to restart the animation when the app resumes.)
if (Application.Current?.IsSuspended ?? false)
{
((ITimeline)this).SkipToFill();
SkipToFill();
}
#endif
}
Expand Down

0 comments on commit 9ec81eb

Please sign in to comment.