Skip to content

Hot to trigger animation in code behind before hiding componetns #13

@adopilot

Description

@adopilot

Hay thanks for your effort, it is very nice component.
Can we trigger animation in code behind.
I saw sample which re-render new components.
But much simpler would be to trigger animation from code behind.
What I am trying to do is to animate component before i hide them
I am trying to implement some kid of toggle button on main page
Button should animate fade out menu before hide them and vice versa.
Here is sample code for animating menu on showing this works pretty nice.
My problem is, I do not know how to animate nav component before I hide id.

Here is sample of MainLayout.razor

@inherits LayoutComponentBase
@using BlazorAnimate
@if (DisplayMenu)
{
    <Animate Animation="Animations.FadeRight"   DurationMs="300"  DelayMs="200">
        <div class="sidebar">
            <NavMenu />
        </div>
    </Animate>
}
<div class="main">
    <div class="top-row px-4">
        <button @onclick="ShowHideMenu">Show / hide</button>
    </div>
    <div class="content px-4">
        @Body
    </div>
</div>
@code {
    private bool DisplayMenu = true;
    private void ShowHideMenu()
        {
            DisplayMenu = !DisplayMenu;
            StateHasChanged();
        }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions