/// <summary>
/// Updates the slide animation.
/// </summary>
/// <param name="control">The control for which the animation needs to be updated.</param>
/// <param name="storyboard">Storyvoard that needs to be updated.</param>
/// <param name="target">The targeted element of the animation.</param>
/// <param name="args"></param>
/// <remarks>
/// Currently the method sets the SpeedRatio of the storyboard to
/// the global <strong>AnimationSpeedRatio</strong> if the local SpeedRatio is null.
/// If the local SpeedRatio value is set, it will be used.
/// </remarks>
protected override void UpdateAnimationOverride(FrameworkElement control, Storyboard storyboard, FrameworkElement target, params object[] args)
{
var orientation = this.Orientation;
var slideMode = this.SlideMode;
if (args.Length > 0 && args[0] is Orientation)
{
orientation = (Orientation)args[0];
}
if (args.Length > 1 && args[1] is SlideMode)
{
slideMode = (SlideMode)args[1];
}
var value = this.GetPixelsToAnimate();
var valueCoeficient = slideMode == SlideMode.Top ? -1 : 1;
var fromValue = this.GetValueDependingOnDirection(value * valueCoeficient, 0.0);
var endValue = this.GetValueDependingOnDirection(0.0, value * valueCoeficient);
var delay = this.GetDelay(target);
var duration = this.GetAnimationDuration() + delay;
if (orientation == Orientation.Vertical)
{
storyboard.Update()
.Animate(target)
.SingleProperty(ClipStartXProperty, 0, 0, delay, 0, duration, 0)
.SingleProperty(ClipStartYProperty, 0, -fromValue, delay, -fromValue, duration, -endValue)
.Easings(this.GetEasing())
.MoveX(0, 0, delay, 0, duration, 0)
.MoveY(0, fromValue, delay, fromValue, duration, endValue)
.Easings(this.GetEasing());
}
else
{
storyboard.Update()
.Animate(target)
.SingleProperty(ClipStartXProperty, 0, -fromValue, delay, -fromValue, duration, -endValue)
.SingleProperty(ClipStartYProperty, 0, 0, delay, 0, duration, 0)
.Easings(this.GetEasing())
.MoveX(0, fromValue, delay, fromValue, duration, endValue)
.MoveY(0, 0, delay, 0, duration, 0)
.Easings(this.GetEasing());
}
ClipControlWhileAnimationIsRunning(target, storyboard);
//DisableControlWhileAnimationIsRunning(target, storyboard);
}