@@ -20,6 +20,7 @@ import {
20
20
Renderer2 ,
21
21
} from '@angular/core' ;
22
22
import { ThemePalette } from '@angular/material/core' ;
23
+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
23
24
24
25
25
26
let nextId = 0 ;
@@ -112,8 +113,12 @@ export class MatBadge implements OnDestroy {
112
113
private _ngZone : NgZone ,
113
114
private _elementRef : ElementRef < HTMLElement > ,
114
115
private _ariaDescriber : AriaDescriber ,
115
- /** @breaking -change 8.0.0 Make _renderer a required param and remove _document. */
116
- private _renderer ?: Renderer2 ) { }
116
+ /**
117
+ * @breaking -change 8.0.0 Make _renderer and _animationMode
118
+ * required params and remove _document.
119
+ */
120
+ private _renderer ?: Renderer2 ,
121
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) private _animationMode ?: string ) { }
117
122
118
123
/** Whether the badge is above the host or not */
119
124
isAbove ( ) : boolean {
@@ -152,14 +157,18 @@ export class MatBadge implements OnDestroy {
152
157
badgeElement . classList . add ( 'mat-badge-content' ) ;
153
158
badgeElement . textContent = this . content ;
154
159
160
+ if ( this . _animationMode === 'NoopAnimations' ) {
161
+ badgeElement . classList . add ( '_mat-animation-noopable' ) ;
162
+ }
163
+
155
164
if ( this . description ) {
156
165
badgeElement . setAttribute ( 'aria-label' , this . description ) ;
157
166
}
158
167
159
168
this . _elementRef . nativeElement . appendChild ( badgeElement ) ;
160
169
161
170
// animate in after insertion
162
- if ( typeof requestAnimationFrame === 'function' ) {
171
+ if ( typeof requestAnimationFrame === 'function' && this . _animationMode !== 'NoopAnimations' ) {
163
172
this . _ngZone . runOutsideAngular ( ( ) => {
164
173
requestAnimationFrame ( ( ) => {
165
174
badgeElement . classList . add ( activeClass ) ;
0 commit comments