Skip to content

Commit

Permalink
Adjust Ripple default duration and radius
Browse files Browse the repository at this point in the history
  • Loading branch information
SKProCH committed Nov 18, 2023
1 parent 39df054 commit e94c4a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Material.Ripple/Ripple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
21 changes: 10 additions & 11 deletions Material.Ripple/RippleHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -73,7 +72,7 @@ public override void OnMessage(object message) {
_secondStepStart = _animationElapsed;
}
}

public override void OnAnimationFrameUpdate() {
if (_animationElapsed >= _duration) return;
Invalidate();
Expand Down

0 comments on commit e94c4a7

Please sign in to comment.