Don't recalculate rippleRadius when its 0 (#14875)

* Don't recalculate rippleRadius when its 0

* Update checkbox.ts

* Delete _calculateRippleRadius instead.

* Update golden

* Update golden, again

* Re-add AfterViewChecked to checkbox.ts

* Update golden
This commit is contained in:
Erik Welander
2019-02-07 11:50:07 -08:00
committed by Jeremy Elbourn
parent 40024703cf
commit d7644ac3be
+2 -23
View File
@@ -49,11 +49,6 @@ import {MAT_CHECKBOX_CLICK_ACTION, MatCheckboxClickAction} from './checkbox-conf
// Increasing integer for generating unique ids for checkbox components.
let nextUniqueId = 0;
// TODO(josephperrott): Revert to constants for ripple radius once 2018 Checkbox updates have
// landed.
// The radius for the checkbox's ripple, in pixels.
let calculatedRippleRadius = 0;
/**
* Provider Expression that allows mat-checkbox to register as a ControlValueAccessor.
* This allows it to support [(ngModel)].
@@ -220,9 +215,8 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
});
}
ngAfterViewChecked() {
this._calculateRippleRadius();
}
// TODO: Delete next major revision.
ngAfterViewChecked() {}
ngOnDestroy() {
this._focusMonitor.stopMonitoring(this._elementRef);
@@ -455,19 +449,4 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
return `mat-checkbox-anim-${animSuffix}`;
}
// TODO(josephperrott): Revert to constants for ripple radius once 2018 Checkbox updates have
// landed.
/**
* Calculate the radius for the ripple based on the ripple elements width. Only calculated once
* for the application.
*/
private _calculateRippleRadius() {
if (!calculatedRippleRadius) {
const rippleWidth =
this._elementRef.nativeElement.querySelector('.mat-checkbox-ripple').clientWidth || 0;
calculatedRippleRadius = rippleWidth / 2;
}
this.ripple.radius = calculatedRippleRadius;
}
}