7

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.

kimondoe
  • 567
  • 2
  • 9
  • 27
  • 1
    Why would you want to do that? Any specific reason ? – FAISAL May 17 '18 at 06:56
  • client's preference. no fancy animation on modal – kimondoe May 17 '18 at 06:58
  • There is a feature request being tracked here in the material repository regarding disabling only the dialog animations [Add possibility to turn off animation of dialog enter/exit](https://github.com/angular/material2/issues/3616) – Eric Phillips Feb 06 '19 at 15:17

2 Answers2

20

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; }
Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215
3

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.

Flavian Hautbois
  • 2,940
  • 6
  • 28
  • 45