File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ import {MAT_CHECKBOX_CLICK_ACTION, MatCheckboxClickAction} from './checkbox-conf
5050// Increasing integer for generating unique ids for checkbox components.
5151let nextUniqueId = 0 ;
5252
53+ // The radius for the checkbox's ripple, in pixels.
54+ let calculatedRippleRadius = 0 ;
55+
5356/**
5457 * Provider Expression that allows mat-checkbox to register as a ControlValueAccessor.
5558 * This allows it to support [(ngModel)].
@@ -208,6 +211,7 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
208211 this . _focusMonitor
209212 . monitor ( this . _inputElement )
210213 . subscribe ( focusOrigin => this . _onInputFocusChange ( focusOrigin ) ) ;
214+ this . _calculateRippleRadius ( ) ;
211215 }
212216
213217 ngOnDestroy ( ) {
@@ -457,4 +461,20 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
457461
458462 return `mat-checkbox-anim-${ animSuffix } ` ;
459463 }
464+
465+ /**
466+ * Calculate the radius for the ripple based on the ripple elements width. Only calculated once
467+ * for the application.
468+ */
469+ private _calculateRippleRadius ( ) {
470+ // setTimeout is used to ensure we delay until the checkbox's ripple is placed in the DOM.
471+ setTimeout ( ( ) => {
472+ if ( ! calculatedRippleRadius ) {
473+ const rippleWidth = parseInt ( window . getComputedStyle (
474+ this . _elementRef . nativeElement . querySelector ( '.mat-checkbox-ripple' ) ) . width ! , 10 ) || 0 ;
475+ calculatedRippleRadius = rippleWidth / 2 ;
476+ }
477+ this . ripple . radius = calculatedRippleRadius ;
478+ } ) ;
479+ }
460480}
You can’t perform that action at this time.
0 commit comments