From e94c4a7fbde3f697865cb547d2b16f60e7c0f438 Mon Sep 17 00:00:00 2001 From: SKProCH Date: Sun, 19 Nov 2023 02:04:19 +0300 Subject: [PATCH] Adjust Ripple default duration and radius --- Material.Ripple/Ripple.cs | 2 +- Material.Ripple/RippleHandler.cs | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Material.Ripple/Ripple.cs b/Material.Ripple/Ripple.cs index 67ae1c2d..5cab6e70 100644 --- a/Material.Ripple/Ripple.cs +++ b/Material.Ripple/Ripple.cs @@ -4,6 +4,6 @@ namespace Material.Ripple { public static class Ripple { public static Easing Easing { get; set; } = new CircularEaseOut(); - public static TimeSpan Duration { get; set; } = new(0, 0, 0, 0, 500); + public static TimeSpan Duration { get; set; } = new(0, 0, 0, 1, 200); } } \ No newline at end of file diff --git a/Material.Ripple/RippleHandler.cs b/Material.Ripple/RippleHandler.cs index 51c0815d..fc773c93 100644 --- a/Material.Ripple/RippleHandler.cs +++ b/Material.Ripple/RippleHandler.cs @@ -4,23 +4,22 @@ using Avalonia.Media; using Avalonia.Rendering.Composition; -namespace Material.Ripple; +namespace Material.Ripple; internal class RippleHandler : CompositionCustomVisualHandler { - private TimeSpan _animationElapsed; - private TimeSpan? _lastServerTime; - private TimeSpan? _secondStepStart; + public static readonly object FirstStepMessage = new(), SecondStepMessage = new(); private readonly IImmutableBrush _brush; private readonly Point _center; - private readonly Easing _easing; private readonly TimeSpan _duration; - private readonly double _opacity; - private readonly bool _transitions; - - public static readonly object FirstStepMessage = new(), SecondStepMessage = new(); + private readonly Easing _easing; private readonly double _maxRadius; + private readonly double _opacity; + private readonly bool _transitions; + private TimeSpan _animationElapsed; + private TimeSpan? _lastServerTime; + private TimeSpan? _secondStepStart; public RippleHandler( IImmutableBrush brush, @@ -37,7 +36,7 @@ public RippleHandler( _transitions = transitions; _center = new Point(positionX, positionY); - _maxRadius = Math.Sqrt(Math.Pow(outerWidth, 2) + Math.Pow(outerHeight, 2)) / 2; + _maxRadius = Math.Sqrt(Math.Pow(outerWidth, 2) + Math.Pow(outerHeight, 2)); } public override void OnRender(ImmediateDrawingContext drawingContext) { @@ -73,7 +72,7 @@ public override void OnMessage(object message) { _secondStepStart = _animationElapsed; } } - + public override void OnAnimationFrameUpdate() { if (_animationElapsed >= _duration) return; Invalidate();