@@ -11,6 +11,7 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion';
11
11
import { DOCUMENT } from '@angular/common' ;
12
12
import { Directive , ElementRef , Inject , Input , NgZone , OnDestroy , Optional } from '@angular/core' ;
13
13
import { ThemePalette } from '@angular/material/core' ;
14
+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
14
15
15
16
16
17
let nextId = 0 ;
@@ -99,7 +100,8 @@ export class MatBadge implements OnDestroy {
99
100
@Optional ( ) @Inject ( DOCUMENT ) private _document : any ,
100
101
private _ngZone : NgZone ,
101
102
private _elementRef : ElementRef ,
102
- private _ariaDescriber : AriaDescriber ) { }
103
+ private _ariaDescriber : AriaDescriber ,
104
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) private _animationMode ?: string ) { }
103
105
104
106
/** Whether the badge is above the host or not */
105
107
isAbove ( ) : boolean {
@@ -136,14 +138,18 @@ export class MatBadge implements OnDestroy {
136
138
badgeElement . classList . add ( 'mat-badge-content' ) ;
137
139
badgeElement . textContent = this . content ;
138
140
141
+ if ( this . _animationMode === 'NoopAnimations' ) {
142
+ badgeElement . classList . add ( '_mat-animation-noopable' ) ;
143
+ }
144
+
139
145
if ( this . description ) {
140
146
badgeElement . setAttribute ( 'aria-label' , this . description ) ;
141
147
}
142
148
143
149
this . _elementRef . nativeElement . appendChild ( badgeElement ) ;
144
150
145
151
// animate in after insertion
146
- if ( typeof requestAnimationFrame === 'function' ) {
152
+ if ( typeof requestAnimationFrame === 'function' && this . _animationMode !== 'NoopAnimations' ) {
147
153
this . _ngZone . runOutsideAngular ( ( ) => {
148
154
requestAnimationFrame ( ( ) => {
149
155
badgeElement . classList . add ( activeClass ) ;
0 commit comments