mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Jeremy Elbourn
parent
40024703cf
commit
d7644ac3be
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user