Browse Source

Cancel an animation instance when the selector turns false.

pull/1885/head
Jumar Macato 8 years ago
parent
commit
ec695433de
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 27
      src/Avalonia.Animation/Animator`1.cs

27
src/Avalonia.Animation/Animator`1.cs

@ -37,12 +37,29 @@ namespace Avalonia.Animation
if (!_isVerifiedAndConverted)
VerifyConvertKeyFrames();
return match
var matchStream = match
.DistinctUntilChanged()
.Publish()
.RefCount();
var activeInstance = matchStream
.Where(p => p)
.Subscribe(_ =>
{
var timerObs = RunKeyFrames(animation, control, onComplete);
});
.Select(p => RunKeyFrames(animation, control, onComplete));
var negationStream = matchStream
.Where(p => !p);
return Observable
.WithLatestFrom(
negationStream,
activeInstance,
(isMatch, instance) =>
{
if (!isMatch && animation.RepeatCount.IsLoop)
instance?.Dispose();
return true;
})
.Subscribe();
}
/// <summary>

Loading…
Cancel
Save