Open In App

Angular PrimeNG PanelMenu Animation Configuration

Last Updated : 13 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more. In this article, we will see the Angular PrimeNG PanelMenu Animation Configuration.

The PanelMenu component is in the form of a panel. It can be considered as a combination of accordion and tree components. The PanelMenu Animation Configuration allows us to configure the default animation when the component appears and then hides each section of the menu.

PanelMenu Animation Configuration properties:

  • transitionOptions: Here we put the animation displayed when we open a panel of the menu. The default value is 400ms cubic-bezier(0.86, 0, 0.07, 1).

 

Syntax:

<p-panelMenu #menu 
    [model]="..." 
    [transitionOptions]="'...'">
</p-panelMenu>

Creating Angular application & Module Installation:

Step 1: Create an Angular application using the following command.

ng new geeks_angular

Step 2: After creating your project folder i.e. geeks_angular, move to it using the following command.

cd geeks_angular

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: The project structure will look like the following:

 

Steps to run the above file: Run the below command

ng serve --save

Example 1: In the following example, we have configured the default animation and used an ease-in for the animation.

  • app.component.html:

HTML




<h1 style="color: green; text-align:center;">
      GeeksforGeeks
</h1>
<h3>
      Angular PrimeNG PanelMenu 
      Animation Configuration
</h3>
  
<p-panelMenu
    #menu
    [model]="items"
    [transitionOptions]="'1s ease-in'">
</p-panelMenu>


  • app.component.ts:

Javascript




import { Component } from "@angular/core";
import { MenuItem } from "primeng/api";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
  
export class AppComponent {
    items: MenuItem[];
    ngOnInit() {
        this.items = [
            {
                label: "Data Structures",
                items: [
                    {
                        label: "Linked List",
                        items: [
                            {
                                label: "Singly Linked List"
                            },
                            {
                                label: "Doubly Linked List"
                            }
                        ]
                    },
                    {
                        label: "Trie"
                    },
                    {
                        label: "Array"
                    }
                ]
            },
            {
                label: "Algorithms",
                items: [
                    {
                        label: "Sorting"
                    },
                    {
                        label: "Searching"
                    }
                ]
            },
            {
                label: "Development",
  
                items: [
                    {
                        label: "Android"
                    },
                    {
                        label: "Web development"
                    }
                ]
            }
        ];
    }
}


  • app.module.ts:

Javascript




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
import { PanelMenuModule } from "primeng/panelmenu";
import { AppComponent } from "./app.component";
import { ButtonModule } from "primeng/button";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PanelMenuModule,
        ButtonModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule {}


Output

 

Example 2: In the following example, we have disabled the animation using transitionOptions.

  • app.component.html:

HTML




<h1 style="color: green; text-align:center;">
      GeeksforGeeks
</h1>
<h3>
      Angular PrimeNG PanelMenu 
      Animation Configuration
</h3>
<p-panelMenu #menu [model]="items" 
        [transitionOptions]="'0s'">
</p-panelMenu>


  • app.component.ts:

Javascript




import { Component } from "@angular/core";
import { MenuItem } from "primeng/api";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
  
export class AppComponent {
    items: MenuItem[];
    ngOnInit() {
        this.items = [
            {
                label: "Data Structures",
                items: [
                    {
                        label: "Linked List",
                        items: [
                            {
                                label: "Singly Linked List"
                            },
                            {
                                label: "Doubly Linked List"
                            }
                        ]
                    },
                    {
                        label: "Trie"
                    },
                    {
                        label: "Array"
                    }
                ]
            },
            {
                label: "Algorithms",
                items: [
                    {
                        label: "Sorting"
                    },
                    {
                        label: "Searching"
                    }
                ]
            },
            {
                label: "Development",
  
                items: [
                    {
                        label: "Android"
                    },
                    {
                        label: "Web development"
                    }
                ]
            }
        ];
    }
}


  • app.module.ts:

Javascript




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
import { PanelMenuModule } from "primeng/panelmenu";
import { AppComponent } from "./app.component";
import { ButtonModule } from "primeng/button";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PanelMenuModule,
        ButtonModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule {}


Output

 

Reference: http://primefaces.org/primeng/panelmenu



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads