Search results

Animations

Accordion supports custom animations for both expand and collapse actions from the provided animation option of Animation library. The animation property also allows you to set Easing, Duration, and various other effects of your choice.

Default animation is given as SlideDown for expanding the panel using Expand animation property and SlideUp for collapsing the panel using Collapse animation property. You can also disable the animation by setting animation Effect as None.

The sample demonstrates some types of animation that suits for Accordion. You can check all the animation effects here

@using Syncfusion.EJ2.Blazor.Navigations
@using Syncfusion.EJ2.Blazor.DropDowns

<div id="container">
    <div id="default" style="padding-bottom:75px;">
        <div class="row">
            <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
                <label> Expand Animation </label>
            </div>
            <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
                <EjsDropDownList TValue="string" Index="0" PopupHeight="150px" placeholder="Select a animate type" DataSource="@AnimationData">
                    <DropDownListEvents ValueChange="ExpandOption" TValue="string"></DropDownListEvents>
                    <DropDownListFieldSettings Value="Text"></DropDownListFieldSettings>
                </EjsDropDownList>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
                <label> Collapse Animation </label>
            </div>
            <div class="col-xs-6 col-sm-6 col-lg-6 col-md-6">
                <EjsDropDownList TValue="string" Index="1" PopupHeight="150px" placeholder="Select a animate type" DataSource="@AnimationData">
                    <DropDownListEvents ValueChange="CollapseOption" TValue="string"></DropDownListEvents>
                    <DropDownListFieldSettings Value="Text"></DropDownListFieldSettings>
                </EjsDropDownList>
            </div>
        </div>
    </div>
    <EjsAccordion>
        <AccordionAnimationSettings>
            <AccordionAnimationCollapse Effect="@CollapseEffect"></AccordionAnimationCollapse>
            <AccordionAnimationExpand Effect="@ExpandEffect"></AccordionAnimationExpand>
        </AccordionAnimationSettings>
        <AccordionItems>
            <AccordionItem Header="ASP.NET" Content="Microsoft ASP.NET is a set of technologies in the Microsoft .NET Framework for building Web applications and XML Web services. ASP.NET pages execute on the server and generate markup such as HTML, WML, or XML that is sent to a desktop or mobile browser. ASP.NET pages use a compiled,event-driven programming model that improves performance and enables the separation of application logic and user interface.">
            </AccordionItem>
            <AccordionItem Header="ASP.NET MVC" Content="The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating Web applications. The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication.">
            </AccordionItem>
            <AccordionItem Header="JavaScript" Content="JavaScript (JS) is an interpreted computer programming language.It was originally implemented as part of web browsers so that client-side scripts could interact with the user, control the browser, communicate asynchronously, and alter the document content that was displayed.More recently, however, it has become common in both Animation development and the creation of desktop applications.">
            </AccordionItem>
        </AccordionItems>
    </EjsAccordion>
</div>

@code{
    public string ExpandEffect { get; set; }
    public string CollapseEffect { get; set; }

    public void ExpandOption(Syncfusion.EJ2.Blazor.DropDowns.ChangeEventArgs<string> args)
    {
        this.ExpandEffect = args.Value as string;
    }

    public void CollapseOption(Syncfusion.EJ2.Blazor.DropDowns.ChangeEventArgs<string> args)
    {
        this.CollapseEffect = args.Value as string;
    }

    List<Animation> AnimationData = new List<Animation>
{
    new Animation() { ID= "Animation1", Text= "SlideDown" },
    new Animation() { ID= "Animation2", Text= "SlideUp" },
    new Animation() { ID= "Animation3", Text= "FadeIn" },
    new Animation() { ID= "Animation4", Text= "FadeOut" },
    new Animation() { ID= "Animation5", Text= "FadeZoomIn" },
    new Animation() { ID= "Animation6", Text= "FadeZoomOut" },
    new Animation() { ID= "Animation7", Text= "ZoomIn" },
    new Animation() { ID= "Animation8", Text= "ZoomOut"},
    new Animation() { ID= "Animation9", Text= "None" }
};

    public class Animation
    {
        public string ID { get; set; }
        public string Text { get; set; }
    }
}

Output be like the below.

Customize Accordion expand or collapse animation behavior