Skip to content

Commit d97a7f6

Browse files
committed
Added DelayBehavior option to XAML animation types
1 parent 59d0b12 commit d97a7f6

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Abstract/Animation.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using Windows.UI.Composition;
67
using Windows.UI.Xaml;
78
using Windows.UI.Xaml.Media.Animation;
89

@@ -103,6 +104,26 @@ public RepeatOption Repeat
103104
typeof(Animation),
104105
new PropertyMetadata(RepeatOption.Once));
105106

107+
/// <summary>
108+
/// Gets or sets the delay behavior for the animation. The default value is set to <see cref="AnimationDelayBehavior.SetInitialValueBeforeDelay"/>.
109+
/// This value is applicable when the current animation is used as either an implicit composition animation, or an explicit composition animation.
110+
/// If the current animation is instead running on the XAML layer (if used through <see cref="CustomAnimation{TValue, TKeyFrame}"/>), it will be ignored.
111+
/// </summary>
112+
public AnimationDelayBehavior DelayBehavior
113+
{
114+
get => (AnimationDelayBehavior)GetValue(DelayBehaviorProperty);
115+
set => SetValue(DelayBehaviorProperty, value);
116+
}
117+
118+
/// <summary>
119+
/// Identifies the <seealso cref="DelayBehavior"/> dependency property.
120+
/// </summary>
121+
public static readonly DependencyProperty DelayBehaviorProperty = DependencyProperty.Register(
122+
nameof(DelayBehavior),
123+
typeof(AnimationDelayBehavior),
124+
typeof(Animation),
125+
new PropertyMetadata(AnimationDelayBehavior.SetInitialValueBeforeDelay));
126+
106127
/// <inheritdoc/>
107128
public abstract AnimationBuilder AppendToBuilder(AnimationBuilder builder, TimeSpan? delayHint, TimeSpan? durationHint, EasingType? easingTypeHint, EasingMode? easingModeHint);
108129
}

Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Abstract/Animation{TValue,TKeyFrame}.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public override AnimationBuilder AppendToBuilder(AnimationBuilder builder, TimeS
104104
delay: Delay ?? delayHint ?? DefaultDelay,
105105
duration: Duration ?? durationHint ?? DefaultDuration,
106106
repeatOption: Repeat,
107+
delayBehavior: DelayBehavior,
107108
build: static (b, s) => s.This.AppendToBuilder(b, s.EasingTypeHint, s.EasingModeHint));
108109
}
109110

Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Abstract/CustomAnimation{TValue,TKeyFrame}.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public override AnimationBuilder AppendToBuilder(AnimationBuilder builder, TimeS
4242
state: (this, easingTypeHint, easingModeHint),
4343
delay: Delay ?? delayHint ?? DefaultDelay,
4444
duration: Duration ?? durationHint ?? DefaultDuration,
45+
delayBehavior: DelayBehavior,
4546
layer: Layer,
4647
build: static (b, s) => s.This.AppendToBuilder(b, s.EasingTypeHint, s.EasingModeHint));
4748
}

Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Abstract/ImplicitAnimation{TValue,TKeyFrame}.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public CompositionAnimation GetAnimation(UIElement element, out string? target)
2929
ExplicitTarget,
3030
Delay ?? DefaultDelay,
3131
Duration ?? DefaultDuration,
32-
Repeat);
32+
Repeat,
33+
DelayBehavior);
3334

3435
var (to, from) = GetParsedValues();
3536

Microsoft.Toolkit.Uwp.UI.Media/Animations/Abstract/EffectAnimation{TEffect,TValue,TKeyFrame}.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ static AnimationBuilder ThrowArgumentNullException()
7070
explicitTarget,
7171
Delay ?? delayHint ?? DefaultDelay,
7272
Duration ?? durationHint ?? DefaultDuration,
73-
Repeat);
73+
Repeat,
74+
DelayBehavior);
7475

7576
AppendToBuilder(keyFrameBuilder, easingTypeHint, easingModeHint);
7677

0 commit comments

Comments
 (0)