@@ -39,6 +39,7 @@ import {
3939 RippleRef ,
4040} from '@angular/material/core' ;
4141import { MAT_CHECKBOX_CLICK_ACTION , MatCheckboxClickAction } from './checkbox-config' ;
42+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
4243
4344
4445// Increasing integer for generating unique ids for checkbox components.
@@ -108,6 +109,7 @@ export const _MatCheckboxMixinBase =
108109 '[class.mat-checkbox-checked]' : 'checked' ,
109110 '[class.mat-checkbox-disabled]' : 'disabled' ,
110111 '[class.mat-checkbox-label-before]' : 'labelPosition == "before"' ,
112+ '[class._mat-animation-noopable]' : `_animationMode === 'NoopAnimations'` ,
111113 } ,
112114 providers : [ MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR ] ,
113115 inputs : [ 'disableRipple' , 'color' , 'tabIndex' ] ,
@@ -184,7 +186,8 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
184186 private _focusMonitor : FocusMonitor ,
185187 @Attribute ( 'tabindex' ) tabIndex : string ,
186188 @Optional ( ) @Inject ( MAT_CHECKBOX_CLICK_ACTION )
187- private _clickAction : MatCheckboxClickAction ) {
189+ private _clickAction : MatCheckboxClickAction ,
190+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ) {
188191 super ( elementRef ) ;
189192
190193 this . tabIndex = parseInt ( tabIndex ) || 0 ;
@@ -322,7 +325,11 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
322325 if ( ! this . _focusRipple && focusOrigin === 'keyboard' ) {
323326 this . _focusRipple = this . ripple . launch ( 0 , 0 , { persistent : true } ) ;
324327 } else if ( ! focusOrigin ) {
325- this . _removeFocusRipple ( ) ;
328+ if ( this . _focusRipple ) {
329+ this . _focusRipple . fadeOut ( ) ;
330+ this . _focusRipple = null ;
331+ }
332+
326333 this . _onTouched ( ) ;
327334 }
328335 }
@@ -390,6 +397,11 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
390397
391398 private _getAnimationClassForCheckStateTransition (
392399 oldState : TransitionCheckState , newState : TransitionCheckState ) : string {
400+ // Don't transition if animations are disabled.
401+ if ( this . _animationMode === 'NoopAnimations' ) {
402+ return '' ;
403+ }
404+
393405 let animSuffix : string = '' ;
394406
395407 switch ( oldState ) {
@@ -420,12 +432,4 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
420432
421433 return `mat-checkbox-anim-${ animSuffix } ` ;
422434 }
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- }
431435}
0 commit comments