Browse Source
Fix naming on Animations & Transitions to better reflect their purpose.
Make RenderDemo & ControlCatalog's TabItems opacity transition faster.
pull/1793/head
Jumar Macato
8 years ago
No known key found for this signature in database
GPG Key ID: B19884DAC3A5BF3F
6 changed files with
11 additions and
12 deletions
-
samples/ControlCatalog/SideBar.xaml
-
samples/RenderDemo/SideBar.xaml
-
src/Avalonia.Animation/AnimationInstance`1.cs
-
src/Avalonia.Animation/Animator`1.cs
-
src/Avalonia.Animation/TransitionInstance.cs
-
src/Avalonia.Animation/Transition`1.cs
|
|
|
@ -36,7 +36,7 @@ |
|
|
|
<Setter Property="Opacity" Value="0.5"/> |
|
|
|
<Setter Property="Transitions"> |
|
|
|
<Transitions> |
|
|
|
<DoubleTransition Property="Opacity" Duration="0:0:0.5"/> |
|
|
|
<DoubleTransition Property="Opacity" Duration="0:0:0.2"/> |
|
|
|
</Transitions> |
|
|
|
</Setter> |
|
|
|
</Style> |
|
|
|
|
|
|
|
@ -37,7 +37,7 @@ |
|
|
|
<Setter Property="Opacity" Value="0.5"/> |
|
|
|
<Setter Property="Transitions"> |
|
|
|
<Transitions> |
|
|
|
<DoubleTransition Property="Opacity" Duration="0:0:0.5"/> |
|
|
|
<DoubleTransition Property="Opacity" Duration="0:0:0.2"/> |
|
|
|
</Transitions> |
|
|
|
</Setter> |
|
|
|
</Style> |
|
|
|
|
|
|
|
@ -11,7 +11,7 @@ namespace Avalonia.Animation |
|
|
|
/// Handles interpolatoin and time-related functions
|
|
|
|
/// for keyframe animations.
|
|
|
|
/// </summary>
|
|
|
|
internal class AnimationsEngine<T> : SingleSubscriberObservableBase<T> |
|
|
|
internal class AnimationInstance<T> : SingleSubscriberObservableBase<T> |
|
|
|
{ |
|
|
|
private T _lastInterpValue; |
|
|
|
private T _firstKFValue; |
|
|
|
@ -37,7 +37,7 @@ namespace Avalonia.Animation |
|
|
|
private Func<double, T, T> _interpolator; |
|
|
|
private IDisposable _timerSubscription; |
|
|
|
|
|
|
|
public AnimationsEngine(Animation animation, Animatable control, Animator<T> animator, Action OnComplete, Func<double, T, T> Interpolator) |
|
|
|
public AnimationInstance(Animation animation, Animatable control, Animator<T> animator, Action OnComplete, Func<double, T, T> Interpolator) |
|
|
|
{ |
|
|
|
if (animation.SpeedRatio <= 0) |
|
|
|
throw new InvalidOperationException("Speed ratio cannot be negative or zero."); |
|
|
|
@ -103,8 +103,8 @@ namespace Avalonia.Animation |
|
|
|
/// </summary>
|
|
|
|
private IDisposable RunKeyFrames(Animation animation, Animatable control, Action onComplete) |
|
|
|
{ |
|
|
|
var stateMachine = new AnimationsEngine<T>(animation, control, this, onComplete, DoInterpolation); |
|
|
|
return control.Bind<T>((AvaloniaProperty<T>)Property, stateMachine, BindingPriority.Animation); |
|
|
|
var instance = new AnimationInstance<T>(animation, control, this, onComplete, DoInterpolation); |
|
|
|
return control.Bind<T>((AvaloniaProperty<T>)Property, instance, BindingPriority.Animation); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
@ -13,13 +13,13 @@ namespace Avalonia.Animation |
|
|
|
/// <summary>
|
|
|
|
/// Handles the timing and lifetime of a <see cref="Transition{T}"/>.
|
|
|
|
/// </summary>
|
|
|
|
public class TransitionsEngine : SingleSubscriberObservableBase<double> |
|
|
|
internal class TransitionIteration : SingleSubscriberObservableBase<double> |
|
|
|
{ |
|
|
|
private IDisposable timerSubscription; |
|
|
|
private TimeSpan startTime; |
|
|
|
private TimeSpan duration; |
|
|
|
|
|
|
|
public TransitionsEngine(TimeSpan Duration) |
|
|
|
public TransitionIteration(TimeSpan Duration) |
|
|
|
{ |
|
|
|
duration = Duration; |
|
|
|
} |
|
|
|
@ -46,9 +46,8 @@ namespace Avalonia.Animation |
|
|
|
protected override void Subscribed() |
|
|
|
{ |
|
|
|
startTime = Timing.GetTickCount(); |
|
|
|
timerSubscription = Timing |
|
|
|
.AnimationsTimer |
|
|
|
.Subscribe(t => TimerTick(t)); |
|
|
|
timerSubscription = Timing.AnimationsTimer |
|
|
|
.Subscribe(t => TimerTick(t)); |
|
|
|
PublishNext(0.0d); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -51,7 +51,7 @@ namespace Avalonia.Animation |
|
|
|
/// <inheritdocs/>
|
|
|
|
public virtual IDisposable Apply(Animatable control, object oldValue, object newValue) |
|
|
|
{ |
|
|
|
var transition = DoTransition(new TransitionsEngine(Duration), (T)oldValue, (T)newValue); |
|
|
|
var transition = DoTransition(new TransitionIteration(Duration), (T)oldValue, (T)newValue); |
|
|
|
return control.Bind<T>((AvaloniaProperty<T>)Property, transition, Data.BindingPriority.Animation); |
|
|
|
} |
|
|
|
|
|
|
|
|