mirror of
https://gitee.com/chinware/atomui.git
synced 2024-12-02 03:47:52 +08:00
Slide 动效完成
This commit is contained in:
parent
a68f8a479c
commit
897b6161ad
@ -4,6 +4,7 @@ using Avalonia.Animation;
|
||||
using Avalonia.Animation.Easings;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
|
||||
namespace AtomUI.Media;
|
||||
@ -72,6 +73,9 @@ public abstract class AbstractMotion : AvaloniaObject, IMotion
|
||||
|
||||
protected static readonly StyledProperty<Rect> MotionRenderBoundsProperty =
|
||||
AvaloniaProperty.Register<AbstractMotion, Rect>(nameof(MotionRenderBounds));
|
||||
|
||||
protected static readonly StyledProperty<ITransform> MotionRenderTransformProperty =
|
||||
AvaloniaProperty.Register<AbstractMotion, ITransform>(nameof(MotionRenderTransform));
|
||||
|
||||
protected double MotionWidth
|
||||
{
|
||||
@ -108,7 +112,13 @@ public abstract class AbstractMotion : AvaloniaObject, IMotion
|
||||
get => GetValue(MotionRenderBoundsProperty);
|
||||
set => SetValue(MotionRenderBoundsProperty, value);
|
||||
}
|
||||
|
||||
|
||||
protected ITransform MotionRenderTransform
|
||||
{
|
||||
get => GetValue(MotionRenderTransformProperty);
|
||||
set => SetValue(MotionRenderTransformProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion(Control target)
|
||||
{
|
||||
if (target is not IMotionAbilityTarget) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Avalonia.Animation.Easings;
|
||||
using AtomUI.Utils;
|
||||
using Avalonia.Animation.Easings;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace AtomUI.Media;
|
||||
@ -29,6 +30,7 @@ public class CollapseMotion : AbstractMotion
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new CubicEaseInOut();
|
||||
originOpacity = NumberUtils.Clamp(originOpacity, 0, 1);
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Avalonia.Animation.Easings;
|
||||
using AtomUI.Utils;
|
||||
using Avalonia.Animation.Easings;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace AtomUI.Media;
|
||||
@ -13,6 +14,7 @@ public class FadeInMotion : AbstractMotion
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new LinearEasing();
|
||||
originOpacity = NumberUtils.Clamp(originOpacity, 0, 1);
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
@ -36,6 +38,7 @@ public class FadeOutMotion : AbstractMotion
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new LinearEasing();
|
||||
originOpacity = NumberUtils.Clamp(originOpacity, 0, 1);
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Avalonia;
|
||||
using AtomUI.Utils;
|
||||
using Avalonia;
|
||||
using Avalonia.Animation.Easings;
|
||||
using Avalonia.Controls;
|
||||
|
||||
@ -6,17 +7,20 @@ namespace AtomUI.Media;
|
||||
|
||||
public class MoveDownInMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? OffsetConfig => GetMotionConfig(MotionRenderOffsetProperty);
|
||||
|
||||
public MoveDownInMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new CircularEaseOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = originOpacity,
|
||||
StartValue = 0d,
|
||||
EndValue = 1d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
@ -42,17 +46,20 @@ public class MoveDownInMotion : AbstractMotion
|
||||
|
||||
public class MoveDownOutMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? OffsetConfig => GetMotionConfig(MotionRenderOffsetProperty);
|
||||
|
||||
public MoveDownOutMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new CircularEaseInOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = originOpacity,
|
||||
StartValue = 1d,
|
||||
EndValue = 0d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
@ -78,17 +85,20 @@ public class MoveDownOutMotion : AbstractMotion
|
||||
|
||||
public class MoveLeftInMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? OffsetConfig => GetMotionConfig(MotionRenderOffsetProperty);
|
||||
|
||||
public MoveLeftInMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new CircularEaseOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = originOpacity,
|
||||
StartValue = 0d,
|
||||
EndValue = 1d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
@ -114,17 +124,20 @@ public class MoveLeftInMotion : AbstractMotion
|
||||
|
||||
public class MoveLeftOutMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? OffsetConfig => GetMotionConfig(MotionRenderOffsetProperty);
|
||||
|
||||
public MoveLeftOutMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new CircularEaseInOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = originOpacity,
|
||||
StartValue = 1d,
|
||||
EndValue = 0d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
@ -150,17 +163,20 @@ public class MoveLeftOutMotion : AbstractMotion
|
||||
|
||||
public class MoveRightInMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? OffsetConfig => GetMotionConfig(MotionRenderOffsetProperty);
|
||||
|
||||
public MoveRightInMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new CircularEaseOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = originOpacity,
|
||||
StartValue = 0d,
|
||||
EndValue = 1d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
@ -186,17 +202,20 @@ public class MoveRightInMotion : AbstractMotion
|
||||
|
||||
public class MoveRightOutMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? OffsetConfig => GetMotionConfig(MotionRenderOffsetProperty);
|
||||
|
||||
public MoveRightOutMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(double originOpacity, TimeSpan duration, Easing? easing = null)
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new CircularEaseInOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = originOpacity,
|
||||
StartValue = 1d,
|
||||
EndValue = 0d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
|
@ -1,6 +1,383 @@
|
||||
namespace AtomUI.Media;
|
||||
using AtomUI.Utils;
|
||||
using Avalonia;
|
||||
using Avalonia.Animation.Easings;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
|
||||
public class SlideUpInMotion
|
||||
namespace AtomUI.Media;
|
||||
|
||||
public class SlideUpInMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? RenderTransformConfig => GetMotionConfig(MotionRenderTransformProperty);
|
||||
|
||||
public SlideUpInMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = 0d,
|
||||
EndValue = 1d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public void ConfigureRenderTransform(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseOut();
|
||||
var config = new MotionConfig(MotionRenderTransformProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.TransformOperations,
|
||||
StartValue = new ScaleTransform(1, 0.8),
|
||||
EndValue = new ScaleTransform(1, 1),
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
public class SlideUpOutMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? RenderTransformConfig => GetMotionConfig(MotionRenderTransformProperty);
|
||||
|
||||
public SlideUpOutMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseIn();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = 1d,
|
||||
EndValue = 0d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public void ConfigureRenderTransform(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseIn();
|
||||
var config = new MotionConfig(MotionRenderTransformProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = new ScaleTransform(1, 1),
|
||||
EndValue = new ScaleTransform(1, 0.8),
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
public class SlideDownInMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? RenderTransformConfig => GetMotionConfig(MotionRenderTransformProperty);
|
||||
private RelativePoint _renderTransformBackup;
|
||||
|
||||
public SlideDownInMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = 0d,
|
||||
EndValue = 1d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public void ConfigureRenderTransform(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseOut();
|
||||
var config = new MotionConfig(MotionRenderTransformProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.TransformOperations,
|
||||
StartValue = new ScaleTransform(1, 0.8),
|
||||
EndValue = new ScaleTransform(1, 1),
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public override void NotifyPreStart()
|
||||
{
|
||||
var target = GetControlTarget();
|
||||
if (target is not null) {
|
||||
_renderTransformBackup = target.RenderTransformOrigin;
|
||||
target.RenderTransformOrigin = RelativePoint.BottomRight;
|
||||
}
|
||||
}
|
||||
|
||||
public override void NotifyStopped()
|
||||
{
|
||||
var target = GetControlTarget();
|
||||
if (target is not null) {
|
||||
target.RenderTransformOrigin = _renderTransformBackup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SlideDownOutMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? RenderTransformConfig => GetMotionConfig(MotionRenderTransformProperty);
|
||||
private RelativePoint _renderTransformBackup;
|
||||
|
||||
public SlideDownOutMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseIn();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = 1d,
|
||||
EndValue = 0d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public void ConfigureRenderTransform(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseIn();
|
||||
var config = new MotionConfig(MotionRenderTransformProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.TransformOperations,
|
||||
StartValue = new ScaleTransform(1, 1),
|
||||
EndValue = new ScaleTransform(1, 0.8),
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public override void NotifyPreStart()
|
||||
{
|
||||
var target = GetControlTarget();
|
||||
if (target is not null) {
|
||||
_renderTransformBackup = target.RenderTransformOrigin;
|
||||
target.RenderTransformOrigin = RelativePoint.BottomRight;
|
||||
}
|
||||
}
|
||||
|
||||
public override void NotifyStopped()
|
||||
{
|
||||
var target = GetControlTarget();
|
||||
if (target is not null) {
|
||||
target.RenderTransformOrigin = _renderTransformBackup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SlideLeftInMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? RenderTransformConfig => GetMotionConfig(MotionRenderTransformProperty);
|
||||
|
||||
public SlideLeftInMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = 0d,
|
||||
EndValue = 1d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public void ConfigureRenderTransform(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseOut();
|
||||
var config = new MotionConfig(MotionRenderTransformProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.TransformOperations,
|
||||
StartValue = new ScaleTransform(0.8, 1),
|
||||
EndValue = new ScaleTransform(1, 1),
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
public class SlideLeftOutMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? RenderTransformConfig => GetMotionConfig(MotionRenderTransformProperty);
|
||||
|
||||
public SlideLeftOutMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseIn();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = 1d,
|
||||
EndValue = 0d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public void ConfigureRenderTransform(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseIn();
|
||||
var config = new MotionConfig(MotionRenderTransformProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = new ScaleTransform(1, 1),
|
||||
EndValue = new ScaleTransform(0.8, 1),
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
public class SlideRightInMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? RenderTransformConfig => GetMotionConfig(MotionRenderTransformProperty);
|
||||
private RelativePoint _renderTransformBackup;
|
||||
|
||||
public SlideRightInMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseOut();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = 0d,
|
||||
EndValue = 1d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public void ConfigureRenderTransform(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseOut();
|
||||
var config = new MotionConfig(MotionRenderTransformProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.TransformOperations,
|
||||
StartValue = new ScaleTransform(0.8, 1),
|
||||
EndValue = new ScaleTransform(1, 1),
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public override void NotifyPreStart()
|
||||
{
|
||||
var target = GetControlTarget();
|
||||
if (target is not null) {
|
||||
_renderTransformBackup = target.RenderTransformOrigin;
|
||||
target.RenderTransformOrigin = new RelativePoint(1, 0, RelativeUnit.Relative);
|
||||
}
|
||||
}
|
||||
|
||||
public override void NotifyStopped()
|
||||
{
|
||||
var target = GetControlTarget();
|
||||
if (target is not null) {
|
||||
target.RenderTransformOrigin = _renderTransformBackup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SlideRightOutMotion : AbstractMotion
|
||||
{
|
||||
public MotionConfig? OpacityConfig => GetMotionConfig(MotionOpacityProperty);
|
||||
public MotionConfig? RenderTransformConfig => GetMotionConfig(MotionRenderTransformProperty);
|
||||
private RelativePoint _renderTransformBackup;
|
||||
|
||||
public SlideRightOutMotion(Control target)
|
||||
: base(target)
|
||||
{}
|
||||
|
||||
public void ConfigureOpacity(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseIn();
|
||||
var config = new MotionConfig(MotionOpacityProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.Double,
|
||||
StartValue = 1d,
|
||||
EndValue = 0d,
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public void ConfigureRenderTransform(TimeSpan duration, Easing? easing = null)
|
||||
{
|
||||
easing ??= new QuinticEaseIn();
|
||||
var config = new MotionConfig(MotionRenderTransformProperty)
|
||||
{
|
||||
TransitionKind = TransitionKind.TransformOperations,
|
||||
StartValue = new ScaleTransform(1, 1),
|
||||
EndValue = new ScaleTransform(0.8, 1),
|
||||
MotionDuration = duration,
|
||||
MotionEasing = easing
|
||||
};
|
||||
AddMotionConfig(config);
|
||||
}
|
||||
|
||||
public override void NotifyPreStart()
|
||||
{
|
||||
var target = GetControlTarget();
|
||||
if (target is not null) {
|
||||
_renderTransformBackup = target.RenderTransformOrigin;
|
||||
target.RenderTransformOrigin = new RelativePoint(1, 0, RelativeUnit.Relative);
|
||||
}
|
||||
}
|
||||
|
||||
public override void NotifyStopped()
|
||||
{
|
||||
var target = GetControlTarget();
|
||||
if (target is not null) {
|
||||
target.RenderTransformOrigin = _renderTransformBackup;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user