Home > Software design >  ion-menu is not doing animation, how to add animation
ion-menu is not doing animation, how to add animation

Time:11-06

I saw it in the ionic documentation but I couldn't find anything about it. When I click on the button to open the menu it is opening normally but without any animation, how do I add an animation for when the menu opens and closes???

      <div class="toatal_pages">
        <ion-menu side="start" menuId="first" contentId="main" >
          <ion-content>
            info
            </ion-content>
        </ion-menu>
        <div class="right> id="main">
        <button (click)="openMenu()"> OPEN MENU</button>
        </div>
      </div>
      
      
        async openMenu() {
          await this.menuController.open();
        }
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

Kindly make sure you are importing it from angular import { MenuController } from '@ionic/angular';

#Try this.

 // template code :
<ion-menu side="start" menuId="first" contentId="main">
  <ion-header>
    <ion-toolbar color="primary">
      <ion-title>Start Menu</ion-title>
    </ion-toolbar>
 </ion-header>
<ion-content>
 <ion-list>
  <ion-item>Menu Item</ion-item>
  <ion-item>Menu Item</ion-item>
  <ion-item>Menu Item</ion-item>
  <ion-item>Menu Item</ion-item>
  <ion-item>Menu Item</ion-item>
</ion-list>
//TypeScript code 
constructor(private menu: MenuController) { }

openMenu() {
    this.menu.enable(true, 'first');
    this.menu.open('first');
}

CodePudding user response:

If you are talking about the default animations then ensure that you have the CSS provided from ionic are imported in the app

For custom animations you will need to follow the following Documentation from Ionic

  • Related