Bug 51424 - Animation does not repeat when repeat func is true
Summary: Animation does not repeat when repeat func is true
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-11 20:32 UTC by John Miller [MSFT]
Modified: 2017-06-08 18:41 UTC (History)
5 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description John Miller [MSFT] 2017-01-11 20:32:01 UTC
**Overview:**

myAnimations.Commit(..., repeat: () => true); does not result in a repeating set of animations.
 
**Steps to Reproduce:** 

Use the following control on a BoxView named "TestBox"

var storyboard = new Animation();
var rotate90 = new Animation(d => TestBox.Rotation = d,
TestBox.Rotation,
TestBox.Rotation + 90,
Easing.SpringOut);

storyboard.Add(0, 0.66, rotate90);
storyboard.Commit(TestBox, "Rotate90Every250", length: 750,
repeat: () => true);

**Actual Results:**

The box will rotate 90 degrees once.
 
**Expected Results:**

The box should rotate 90 degrees every ~250ms. 
 
**Build Date & Platform:**

Tested on iOS
XF 2.3.3.180
 
**Additional Information:**

This seems to be related to:
https://github.com/xamarin/Xamarin.Forms/blob/2.3.3/Xamarin.Forms.Core/Animation.cs#L93-L94

This private field is set and then subanimations do to repeat. This hack works around it:

var storyboard = new Animation();
var rotate90 = new Animation(d => TestBox.Rotation = d,
TestBox.Rotation,
TestBox.Rotation + 90,
Easing.SpringOut);

storyboard.Add(0, 0.66, rotate90);
storyboard.Commit(TestBox, "Rotate90Every250", length: 750,
finished: (d, done) => SetPrivateField(rotate90, "_finishedTriggered", false),
repeat: () => true);

public static void SetPrivateField<T>(T item, string fieldName, object value)
{
    typeof(T).GetTypeInfo().GetDeclaredField(fieldName).SetValue(item, value);
}

Older issue: https://bugzilla.xamarin.com/show_bug.cgi?id=26580
Forum discussion: https://forums.xamarin.com/discussion/comment/154484/#Comment_154484
Comment 1 Stephane Delcroix 2017-06-07 07:47:57 UTC
https://github.com/xamarin/Xamarin.Forms/pull/974
Comment 2 dhaligas 2017-06-07 15:37:07 UTC
awesome been waiting for this one
Comment 3 Stephane Delcroix 2017-06-08 18:41:29 UTC
should be fixed in 2.3.6-pre1