From d41ae3a3371e6b36ea7263d05acebd4659b963e5 Mon Sep 17 00:00:00 2001 From: Denny09310 Date: Wed, 17 Sep 2025 21:17:20 +0200 Subject: [PATCH 1/7] feat: added event to handle 'onanimationend' --- src/LumexUI/Infrastructure/EventHandlers.cs | 20 ++++++++++++++++++++ src/LumexUI/wwwroot/js/LumexUI.js | 13 ++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/LumexUI/Infrastructure/EventHandlers.cs b/src/LumexUI/Infrastructure/EventHandlers.cs index 07c52d99..94f825fb 100644 --- a/src/LumexUI/Infrastructure/EventHandlers.cs +++ b/src/LumexUI/Infrastructure/EventHandlers.cs @@ -10,6 +10,26 @@ namespace LumexUI.Infrastructure; /// Configures event handlers for the components. /// [EventHandler( "onclickoutside", typeof( EventArgs ), enableStopPropagation: true, enablePreventDefault: true )] +[EventHandler( "onanimationend", typeof( AnimationEventArgs ), enableStopPropagation: true, enablePreventDefault: true )] public static class EventHandlers { } + +/// +/// Arguments for the animation events. +/// +public class AnimationEventArgs : EventArgs +{ + /// + /// Gets the name of the animation. + /// + public string AnimationName { get; set; } = string.Empty; + /// + /// Gets the elapsed time of the animation in seconds. + /// + public double ElapsedTime { get; set; } + /// + /// Gets the name of the pseudo-element the animation is applied to. + /// + public string PseudoElement { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/src/LumexUI/wwwroot/js/LumexUI.js b/src/LumexUI/wwwroot/js/LumexUI.js index ee219f8f..7ffe7ed1 100644 --- a/src/LumexUI/wwwroot/js/LumexUI.js +++ b/src/LumexUI/wwwroot/js/LumexUI.js @@ -8,4 +8,15 @@ export const Lumex = { elementReference }; -window['Lumex'] = Lumex \ No newline at end of file +window['Lumex'] = Lumex + +Blazor.registerCustomEventType('animationend', { + browserEventName: 'animationend', + createEventArgs: event => { + return { + AnimationName: event.animationName, + ElapsedTime: event.elapsedTime, + PseudoElement: event.pseudoElement + }; + } +}) \ No newline at end of file From 93f4a14c5363e1ece383de8fcb358ee852b97944 Mon Sep 17 00:00:00 2001 From: Denny09310 Date: Wed, 17 Sep 2025 21:17:28 +0200 Subject: [PATCH 2/7] feat: added exiting animation css --- src/LumexUI/Styles/_theme.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/LumexUI/Styles/_theme.css b/src/LumexUI/Styles/_theme.css index 45ed19c8..885e4410 100644 --- a/src/LumexUI/Styles/_theme.css +++ b/src/LumexUI/Styles/_theme.css @@ -172,6 +172,7 @@ /* Animations */ --animate-enter: enter 150ms ease-out normal both; + --animate-exit: exit 150ms ease-out normal both; --animate-shimmer: shimmer 2s infinite; --animate-sway: sway 0.75s infinite; --animate-blink: blink 1.5s infinite both; @@ -189,6 +190,18 @@ } } + @keyframes exit { + 0% { + opacity: 1; + transform: translateZ(0) scale(1); + } + + 100% { + opacity: 0; + transform: translateZ(0) scale(0.85); + } + } + @keyframes shimmer { 100% { translate: 100%; From 90288b05289116f5831cfd9a0e3c48e6be574997 Mon Sep 17 00:00:00 2001 From: Denny09310 Date: Wed, 17 Sep 2025 21:17:44 +0200 Subject: [PATCH 3/7] feat: adding state to keep the animation running before closing --- src/LumexUI/Components/Popover/LumexPopover.razor.cs | 7 +++++++ .../Components/Popover/LumexPopoverContent.razor | 8 +++++--- .../Components/Popover/LumexPopoverContent.razor.cs | 10 ++++++++++ src/LumexUI/Styles/Popover.cs | 3 ++- .../Components/Dropdown/DropdownTests.razor | 2 +- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/LumexUI/Components/Popover/LumexPopover.razor.cs b/src/LumexUI/Components/Popover/LumexPopover.razor.cs index fdca7a5c..95974aa0 100644 --- a/src/LumexUI/Components/Popover/LumexPopover.razor.cs +++ b/src/LumexUI/Components/Popover/LumexPopover.razor.cs @@ -99,6 +99,7 @@ public partial class LumexPopover : LumexComponentBase, ISlotComponent [Parameter] public PopoverSlots? Classes { get; set; } + internal bool IsVisible { get; set; } internal bool IsTooltip { get; private set; } internal PopoverOptions Options { get; private set; } internal Dictionary Slots { get; private set; } = []; @@ -126,6 +127,11 @@ protected override void OnParametersSet() IsTooltip = value is "tooltip"; } + if( Open && !IsVisible ) + { + IsVisible = true; + } + Options = new PopoverOptions( this ); var popover = Popover.Style( TwMerge ); @@ -157,6 +163,7 @@ internal async Task TriggerAsync() internal Task OpenAsync() { Open = true; + IsVisible = true; return OpenChanged.InvokeAsync( true ); } diff --git a/src/LumexUI/Components/Popover/LumexPopoverContent.razor b/src/LumexUI/Components/Popover/LumexPopoverContent.razor index 6d42d0d3..8206670b 100644 --- a/src/LumexUI/Components/Popover/LumexPopoverContent.razor +++ b/src/LumexUI/Components/Popover/LumexPopoverContent.razor @@ -1,9 +1,11 @@ @namespace LumexUI @inherits LumexComponentBase -@if( Popover.Open ) +@if( Popover.IsVisible ) { - +