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
50
50
// Increasing integer for generating unique ids for checkbox components.
51
51
let nextUniqueId = 0 ;
52
52
53
+ // The radius for the checkbox's ripple, in pixels.
54
+ let calculatedRippleRadius = 0 ;
55
+
53
56
/**
54
57
* Provider Expression that allows mat-checkbox to register as a ControlValueAccessor.
55
58
* This allows it to support [(ngModel)].
@@ -208,6 +211,7 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
208
211
this . _focusMonitor
209
212
. monitor ( this . _inputElement )
210
213
. subscribe ( focusOrigin => this . _onInputFocusChange ( focusOrigin ) ) ;
214
+ this . _calculateRippleRadius ( ) ;
211
215
}
212
216
213
217
ngOnDestroy ( ) {
@@ -457,4 +461,20 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
457
461
458
462
return `mat-checkbox-anim-${ animSuffix } ` ;
459
463
}
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
+ }
460
480
}
You can’t perform that action at this time.
0 commit comments