Xamarin.Motion.Animation.GetCallback C# (CSharp) Method

GetCallback() public method

public GetCallback ( ) : Action
return Action
        public Action<double> GetCallback()
        {
            Action<double> result = f => {
                step (easing (f));
                foreach (var animation in children) {
                    if (animation.finishedTriggered)
                        continue;

                    double val = Math.Max (0.0f, Math.Min (1.0f, (f - animation.beginAt) / (animation.finishAt - animation.beginAt)));

                    if (val <= 0.0f) // not ready to process yet
                        continue;

                    var callback = animation.GetCallback ();
                    callback (val);

                    if (val >= 1.0f) {
                        animation.finishedTriggered = true;
                        if (animation.finished != null)
                            animation.finished ();
                    }
                }
            };
            return result;
        }

Usage Example

Example #1
0
 public static void Animate(this Animatable self, string name, Animation animation, uint rate = 16, uint length = 250,
                            Func <double, double> easing = null, Action <double, bool> finished = null, Func <bool> repeat = null)
 {
     self.Animate(name, animation.GetCallback(), rate, length, easing, finished, repeat);
 }