mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-26 03:00:28 +08:00
Add IAnimationAwareControl
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
public interface IAnimationAwareControl
|
||||
{
|
||||
bool IsMotionEnabled { get; set; }
|
||||
bool IsWaveAnimationEnabled { get; set; }
|
||||
Control PropertyBindTarget { get; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using AtomUI.Controls;
|
||||
using AtomUI.Theme.Data;
|
||||
using AtomUI.Theme.Styling;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.LogicalTree;
|
||||
|
||||
namespace AtomUI.Theme.Utils;
|
||||
|
||||
public static class AnimationAwareControlExtensions
|
||||
{
|
||||
public static void BindAnimationProperties(this IAnimationAwareControl animationAwareControl,
|
||||
AvaloniaProperty isMotionEnabledProperty,
|
||||
AvaloniaProperty isWaveAnimationEnabledProperty)
|
||||
{
|
||||
var bindTarget = animationAwareControl.PropertyBindTarget;
|
||||
bindTarget.AttachedToLogicalTree += (object? sender, LogicalTreeAttachmentEventArgs args) =>
|
||||
{
|
||||
if (sender is Control control)
|
||||
{
|
||||
TokenResourceBinder.CreateTokenBinding(control, isMotionEnabledProperty, SharedTokenKey.EnableMotion);
|
||||
TokenResourceBinder.CreateTokenBinding(control, isWaveAnimationEnabledProperty, SharedTokenKey.EnableWaveAnimation);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user