Browse Source
Merge pull request #6064 from AvaloniaUI/fixes/6063-animation-neutral-value
Fix fetching neutral value in animations.
pull/6067/head
Jumar Macato
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
20 additions and
1 deletions
-
src/Avalonia.Animation/AnimationInstance`1.cs
|
|
|
@ -5,6 +5,7 @@ using Avalonia.Animation.Animators; |
|
|
|
using Avalonia.Animation.Utils; |
|
|
|
using Avalonia.Data; |
|
|
|
using Avalonia.Reactive; |
|
|
|
using JetBrains.Annotations; |
|
|
|
|
|
|
|
namespace Avalonia.Animation |
|
|
|
{ |
|
|
|
@ -45,8 +46,9 @@ namespace Avalonia.Animation |
|
|
|
_onCompleteAction = OnComplete; |
|
|
|
_interpolator = Interpolator; |
|
|
|
_baseClock = baseClock; |
|
|
|
_neutralValue = (T)_targetControl.GetValue(_animator.Property); |
|
|
|
control.PropertyChanged += ControlPropertyChanged; |
|
|
|
|
|
|
|
UpdateNeutralValue(); |
|
|
|
FetchProperties(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -216,5 +218,22 @@ namespace Avalonia.Animation |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void UpdateNeutralValue() |
|
|
|
{ |
|
|
|
var property = _animator.Property; |
|
|
|
var baseValue = _targetControl.GetBaseValue(property, BindingPriority.LocalValue); |
|
|
|
|
|
|
|
_neutralValue = baseValue != AvaloniaProperty.UnsetValue ? |
|
|
|
(T)baseValue : (T)_targetControl.GetValue(property); |
|
|
|
} |
|
|
|
|
|
|
|
private void ControlPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e) |
|
|
|
{ |
|
|
|
if (e.Property == _animator.Property && e.Priority > BindingPriority.Animation) |
|
|
|
{ |
|
|
|
UpdateNeutralValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|