@@ -39,6 +39,7 @@ import {
39
39
RippleRef ,
40
40
} from '@angular/material/core' ;
41
41
import { MAT_CHECKBOX_CLICK_ACTION , MatCheckboxClickAction } from './checkbox-config' ;
42
+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
42
43
43
44
44
45
// Increasing integer for generating unique ids for checkbox components.
@@ -108,6 +109,7 @@ export const _MatCheckboxMixinBase =
108
109
'[class.mat-checkbox-checked]' : 'checked' ,
109
110
'[class.mat-checkbox-disabled]' : 'disabled' ,
110
111
'[class.mat-checkbox-label-before]' : 'labelPosition == "before"' ,
112
+ '[class._mat-animation-noopable]' : `_animationMode === 'NoopAnimations'` ,
111
113
} ,
112
114
providers : [ MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR ] ,
113
115
inputs : [ 'disableRipple' , 'color' , 'tabIndex' ] ,
@@ -184,7 +186,8 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
184
186
private _focusMonitor : FocusMonitor ,
185
187
@Attribute ( 'tabindex' ) tabIndex : string ,
186
188
@Optional ( ) @Inject ( MAT_CHECKBOX_CLICK_ACTION )
187
- private _clickAction : MatCheckboxClickAction ) {
189
+ private _clickAction : MatCheckboxClickAction ,
190
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ) {
188
191
super ( elementRef ) ;
189
192
190
193
this . tabIndex = parseInt ( tabIndex ) || 0 ;
@@ -322,7 +325,11 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
322
325
if ( ! this . _focusRipple && focusOrigin === 'keyboard' ) {
323
326
this . _focusRipple = this . ripple . launch ( 0 , 0 , { persistent : true } ) ;
324
327
} else if ( ! focusOrigin ) {
325
- this . _removeFocusRipple ( ) ;
328
+ if ( this . _focusRipple ) {
329
+ this . _focusRipple . fadeOut ( ) ;
330
+ this . _focusRipple = null ;
331
+ }
332
+
326
333
this . _onTouched ( ) ;
327
334
}
328
335
}
@@ -390,6 +397,11 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
390
397
391
398
private _getAnimationClassForCheckStateTransition (
392
399
oldState : TransitionCheckState , newState : TransitionCheckState ) : string {
400
+ // Don't transition if animations are disabled.
401
+ if ( this . _animationMode === 'NoopAnimations' ) {
402
+ return '' ;
403
+ }
404
+
393
405
let animSuffix : string = '' ;
394
406
395
407
switch ( oldState ) {
@@ -420,12 +432,4 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
420
432
421
433
return `mat-checkbox-anim-${ animSuffix } ` ;
422
434
}
423
-
424
- /** Fades out the focus state ripple. */
425
- private _removeFocusRipple ( ) : void {
426
- if ( this . _focusRipple ) {
427
- this . _focusRipple . fadeOut ( ) ;
428
- this . _focusRipple = null ;
429
- }
430
- }
431
435
}
0 commit comments