summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-06-08 20:38:45 +0200
committerGitHub <noreply@github.com>2017-06-08 20:38:45 +0200
commit3a0aa901641e60aacc1213ff9db94d5b7c3107b3 (patch)
tree7c58dc9a3843431ab38e30a048d425038d75f7c2 /Xamarin.Forms.Core
parent0d3611ccce5db468bf0a6bbccd5ad4e96884bce0 (diff)
downloadxamarin-forms-3a0aa901641e60aacc1213ff9db94d5b7c3107b3.tar.gz
xamarin-forms-3a0aa901641e60aacc1213ff9db94d5b7c3107b3.tar.bz2
xamarin-forms-3a0aa901641e60aacc1213ff9db94d5b7c3107b3.zip
[C] reset children animation on repeat (#974)
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r--Xamarin.Forms.Core/Animation.cs6
-rw-r--r--Xamarin.Forms.Core/AnimationExtensions.cs21
2 files changed, 22 insertions, 5 deletions
diff --git a/Xamarin.Forms.Core/Animation.cs b/Xamarin.Forms.Core/Animation.cs
index 03cded1e..05348e31 100644
--- a/Xamarin.Forms.Core/Animation.cs
+++ b/Xamarin.Forms.Core/Animation.cs
@@ -112,6 +112,12 @@ namespace Xamarin.Forms
return result;
}
+ internal void ResetChildren()
+ {
+ foreach (var anim in _children)
+ anim._finishedTriggered = false;
+ }
+
public Animation Insert(double beginAt, double finishAt, Animation animation)
{
Add(beginAt, finishAt, animation);
diff --git a/Xamarin.Forms.Core/AnimationExtensions.cs b/Xamarin.Forms.Core/AnimationExtensions.cs
index 2256cb73..aed317af 100644
--- a/Xamarin.Forms.Core/AnimationExtensions.cs
+++ b/Xamarin.Forms.Core/AnimationExtensions.cs
@@ -71,7 +71,18 @@ namespace Xamarin.Forms
public static void Animate(this IAnimatable self, string name, Animation animation, uint rate = 16, uint length = 250, Easing easing = null, Action<double, bool> finished = null,
Func<bool> repeat = null)
{
- self.Animate(name, animation.GetCallback(), rate, length, easing, finished, repeat);
+ if (repeat == null)
+ self.Animate(name, animation.GetCallback(), rate, length, easing, finished, null);
+ else {
+ Func<bool> r = () =>
+ {
+ var val = repeat();
+ if (val)
+ animation.ResetChildren();
+ return val;
+ };
+ self.Animate(name, animation.GetCallback(), rate, length, easing, finished, r);
+ }
}
public static void Animate(this IAnimatable self, string name, Action<double> callback, double start, double end, uint rate = 16, uint length = 250, Easing easing = null,
@@ -232,15 +243,15 @@ namespace Xamarin.Forms
Info info;
if (tweener != null && s_animations.TryGetValue(tweener.Handle, out info))
{
- var repeat = false;
- if (info.Repeat != null)
- repeat = info.Repeat();
-
IAnimatable owner;
if (info.Owner.TryGetTarget(out owner))
owner.BatchBegin();
info.Callback(tweener.Value);
+ var repeat = false;
+ if (info.Repeat != null)
+ repeat = info.Repeat();
+
if (!repeat)
{
s_animations.Remove(tweener.Handle);