Browse Source

Cache property changed delegate.

pull/6072/head
Steven Kirk 5 years ago
parent
commit
038805bb26
  1. 6
      src/Avalonia.Animation/AnimationInstance`1.cs

6
src/Avalonia.Animation/AnimationInstance`1.cs

@ -37,6 +37,7 @@ namespace Avalonia.Animation
private IDisposable _timerSub;
private readonly IClock _baseClock;
private IClock _clock;
private EventHandler<AvaloniaPropertyChangedEventArgs> _propertyChangedDelegate;
public AnimationInstance(Animation animation, Animatable control, Animator<T> animator, IClock baseClock, Action OnComplete, Func<double, T, T> Interpolator)
{
@ -79,7 +80,7 @@ namespace Avalonia.Animation
// Animation may have been stopped before it has finished.
ApplyFinalFill();
_targetControl.PropertyChanged -= ControlPropertyChanged;
_targetControl.PropertyChanged -= _propertyChangedDelegate;
_timerSub?.Dispose();
_clock.PlayState = PlayState.Stop;
}
@ -88,7 +89,8 @@ namespace Avalonia.Animation
{
_clock = new Clock(_baseClock);
_timerSub = _clock.Subscribe(Step);
_targetControl.PropertyChanged += ControlPropertyChanged;
_propertyChangedDelegate ??= ControlPropertyChanged;
_targetControl.PropertyChanged += _propertyChangedDelegate;
UpdateNeutralValue();
}

Loading…
Cancel
Save