Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable animations in angular material

I have used angular material version: 5.2.1

And wanted to know how to disable their animations, especially the matDialog.

I have tried @.disabled but no luck.

like image 361
kimondoe Avatar asked May 17 '18 06:05

kimondoe


2 Answers

You can use NoopAnimationsModule by angular material

import {NoopAnimationsModule} from '@angular/platform-browser/animations';

@NgModule({
  ...
  imports: [NoopAnimationsModule],
  ...
})
export class PizzaPartyAppModule { }

Or if you want to remove transition on some specific components you can do it via CSS like this

.mat-dialog{ transition: none; }
like image 97
Pardeep Jain Avatar answered Sep 28 '22 02:09

Pardeep Jain


The approved answer does not work and is not consistent with Angular docs, at least since Angular 6. To disable animations in Angular 6 to 13, from the official doc, use:

// In app.component.ts

import { Component, HostBinding } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent {
  @HostBinding('@.disabled')
  public animationsDisabled = true;  // Set to true to disable animations
}

This is useful for end-to-end (E2E) testing.

like image 40
Flavian Hautbois Avatar answered Sep 28 '22 03:09

Flavian Hautbois