Skip to content

Commit c2a20c4

Browse files
authored
refactor(multiple): clean up ripple overrides in MDC components (#23376)
Now that the default ripple timings have been aligned to MDC, we don't have to make any overrides in the various MDC components.
1 parent b5b262d commit c2a20c4

22 files changed

+10
-141
lines changed

src/material-experimental/mdc-button/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ng_module(
2828
deps = [
2929
"//src/cdk/platform",
3030
"//src/material-experimental/mdc-core",
31-
"@npm//@material/ripple",
3231
],
3332
)
3433

src/material-experimental/mdc-button/button-base.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ import {
1717
mixinColor,
1818
mixinDisabled,
1919
mixinDisableRipple,
20-
RippleAnimationConfig
2120
} from '@angular/material-experimental/mdc-core';
22-
import {numbers} from '@material/ripple';
2321
import {FocusOrigin} from '@angular/cdk/a11y';
2422

2523
/** Inputs common to all buttons. */
@@ -38,12 +36,6 @@ export const MAT_BUTTON_HOST = {
3836
'[class.mat-mdc-button-base]': 'true',
3937
};
4038

41-
/** Configuration for the ripple animation. */
42-
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
43-
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
44-
exitDuration: numbers.FG_DEACTIVATION_MS
45-
};
46-
4739
/** List of classes to add to buttons instances based on host attribute selector. */
4840
const HOST_SELECTOR_MDC_CLASS_PAIR: {selector: string, mdcClasses: string[]}[] = [
4941
{
@@ -86,12 +78,6 @@ export const _MatButtonMixin = mixinColor(mixinDisabled(mixinDisableRipple(class
8678
@Directive()
8779
export class MatButtonBase extends _MatButtonMixin implements CanDisable, CanColor,
8880
CanDisableRipple {
89-
/** The ripple animation configuration to use for the buttons. */
90-
_rippleAnimation: RippleAnimationConfig =
91-
this._animationMode === 'NoopAnimations' ?
92-
{enterDuration: 0, exitDuration: 0} :
93-
RIPPLE_ANIMATION_CONFIG;
94-
9581
/** Whether the ripple is centered on the button. */
9682
_isRippleCentered = false;
9783

src/material-experimental/mdc-button/button.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<span class="mat-mdc-focus-indicator"></span>
1818

1919
<span matRipple class="mat-mdc-button-ripple"
20-
[matRippleAnimation]="_rippleAnimation"
2120
[matRippleDisabled]="_isRippleDisabled()"
2221
[matRippleCentered]="_isRippleCentered"
2322
[matRippleTrigger]="_elementRef.nativeElement"></span>

src/material-experimental/mdc-checkbox/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ ng_module(
2929
"@npm//@angular/core",
3030
"@npm//@angular/forms",
3131
"@npm//@material/checkbox",
32-
"@npm//@material/ripple",
3332
],
3433
)
3534

src/material-experimental/mdc-checkbox/checkbox.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
<div class="mat-mdc-checkbox-ripple mat-mdc-focus-indicator" mat-ripple
3636
[matRippleTrigger]="checkbox"
3737
[matRippleDisabled]="disableRipple || disabled"
38-
[matRippleCentered]="true"
39-
[matRippleAnimation]="_rippleAnimation"></div>
38+
[matRippleCentered]="true"></div>
4039
</div>
4140
<label #label
4241
[for]="inputId"

src/material-experimental/mdc-checkbox/checkbox.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
MatCheckboxDefaultOptions, MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY
3131
} from '@angular/material/checkbox';
3232
import {
33-
RippleAnimationConfig,
3433
mixinColor,
3534
mixinDisabled,
3635
CanColor,
@@ -39,7 +38,6 @@ import {
3938
} from '@angular/material-experimental/mdc-core';
4039
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
4140
import {MDCCheckboxAdapter, MDCCheckboxFoundation} from '@material/checkbox';
42-
import {numbers} from '@material/ripple';
4341

4442
let nextUniqueId = 0;
4543

@@ -66,13 +64,6 @@ const _MatCheckboxBase = mixinColor(mixinDisabled(class {
6664
constructor(public _elementRef: ElementRef) {}
6765
}));
6866

69-
70-
/** Configuration for the ripple animation. */
71-
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
72-
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
73-
exitDuration: numbers.FG_DEACTIVATION_MS,
74-
};
75-
7667
@Component({
7768
selector: 'mat-checkbox',
7869
templateUrl: 'checkbox.html',
@@ -197,9 +188,6 @@ export class MatCheckbox extends _MatCheckboxBase implements AfterViewInit, OnDe
197188
/** The set of classes that should be applied to the native input. */
198189
_classes: {[key: string]: boolean} = {'mdc-checkbox__native-control': true};
199190

200-
/** Animation config for the ripple. */
201-
_rippleAnimation = RIPPLE_ANIMATION_CONFIG;
202-
203191
/** ControlValueAccessor onChange */
204192
private _cvaOnChange = (_: boolean) => {};
205193

src/material-experimental/mdc-chips/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ ng_module(
2727
"@npm//@angular/core",
2828
"@npm//@angular/forms",
2929
"@npm//@material/chips",
30-
"@npm//@material/ripple",
3130
],
3231
)
3332

src/material-experimental/mdc-chips/chip-option.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<span class="mdc-chip__ripple"></span>
22

33
<span matRipple class="mat-mdc-chip-ripple"
4-
[matRippleAnimation]="_rippleAnimation"
54
[matRippleDisabled]="_isRippleDisabled()"
65
[matRippleCentered]="_isRippleCentered"
76
[matRippleTrigger]="_elementRef.nativeElement"></span>

src/material-experimental/mdc-chips/chip-row.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<span class="mdc-chip__ripple"></span>
33

44
<span matRipple class="mat-mdc-chip-ripple"
5-
[matRippleAnimation]="_rippleAnimation"
65
[matRippleDisabled]="_isRippleDisabled()"
76
[matRippleCentered]="_isRippleCentered"
87
[matRippleTrigger]="_elementRef.nativeElement"></span>
@@ -29,4 +28,4 @@
2928
<ng-template #defaultMatChipEditInput>
3029
<span matChipEditInput></span>
3130
</ng-template>
32-
</div>
31+
</div>

src/material-experimental/mdc-chips/chip.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<span class="mdc-chip__ripple"></span>
22

33
<span matRipple class="mat-mdc-chip-ripple"
4-
[matRippleAnimation]="_rippleAnimation"
54
[matRippleDisabled]="_isRippleDisabled()"
65
[matRippleCentered]="_isRippleCentered"
76
[matRippleTrigger]="_elementRef.nativeElement"></span>

src/material-experimental/mdc-chips/chip.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ import {
3939
mixinColor,
4040
mixinDisableRipple,
4141
mixinTabIndex,
42-
RippleAnimationConfig,
4342
RippleGlobalOptions,
4443
} from '@angular/material-experimental/mdc-core';
4544
import {deprecated} from '@material/chips';
46-
import {numbers} from '@material/ripple';
4745
import {SPACE, ENTER, hasModifierKey} from '@angular/cdk/keycodes';
4846
import {Subject} from 'rxjs';
4947
import {takeUntil} from 'rxjs/operators';
@@ -64,12 +62,6 @@ export interface MatChipEvent {
6462
chip: MatChip;
6563
}
6664

67-
/** Configuration for the ripple animation. */
68-
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
69-
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
70-
exitDuration: numbers.FG_DEACTIVATION_MS
71-
};
72-
7365
/**
7466
* Directive to add MDC CSS to non-basic chips.
7567
* @docs-private
@@ -120,9 +112,6 @@ const _MatChipMixinBase = mixinTabIndex(mixinColor(mixinDisableRipple(MatChipBas
120112
})
121113
export class MatChip extends _MatChipMixinBase implements AfterContentInit, AfterViewInit,
122114
CanColor, CanDisableRipple, CanDisable, HasTabIndex, OnDestroy {
123-
/** The ripple animation configuration to use for the chip. */
124-
readonly _rippleAnimation: RippleAnimationConfig = RIPPLE_ANIMATION_CONFIG;
125-
126115
/** Whether the ripple is centered on the chip. */
127116
readonly _isRippleCentered = false;
128117

src/material-experimental/mdc-list/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ ng_module(
3232
"@npm//@angular/core",
3333
"@npm//@angular/forms",
3434
"@npm//@material/list",
35-
"@npm//@material/ripple",
3635
],
3736
)
3837

src/material-experimental/mdc-list/list-base.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
setLines,
3131
} from '@angular/material-experimental/mdc-core';
3232
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
33-
import {numbers} from '@material/ripple';
3433
import {Subscription} from 'rxjs';
3534
import {startWith} from 'rxjs/operators';
3635
import {MatListAvatarCssMatStyler, MatListIconCssMatStyler} from './list-styling';
@@ -97,20 +96,10 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri
9796
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS)
9897
globalRippleOptions?: RippleGlobalOptions,
9998
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
100-
// We have to clone the object, because we don't want to mutate a global value when we assign
101-
// the `animation` further down. The downside of doing this is that the ripple renderer won't
102-
// pick up dynamic changes to `disabled`, but it's not something we officially support.
103-
this.rippleConfig = {...(globalRippleOptions || {})};
99+
this.rippleConfig = globalRippleOptions || {};
104100
this._hostElement = this._elementRef.nativeElement;
105101
this._noopAnimations = animationMode === 'NoopAnimations';
106102

107-
if (!this.rippleConfig.animation) {
108-
this.rippleConfig.animation = {
109-
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
110-
exitDuration: numbers.FG_DEACTIVATION_MS
111-
};
112-
}
113-
114103
if (!this._listBase._isNonInteractive) {
115104
this._initInteractiveListItem();
116105
}

src/material-experimental/mdc-menu/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ng_module(
2828
"@npm//@angular/animations",
2929
"@npm//@angular/common",
3030
"@npm//@angular/core",
31-
"@npm//@material/ripple",
3231
],
3332
)
3433

src/material-experimental/mdc-menu/menu-item.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
<span class="mdc-list-item__primary-text"><ng-content></ng-content></span>
33
<div class="mat-mdc-menu-ripple" matRipple
44
[matRippleDisabled]="disableRipple || disabled"
5-
[matRippleTrigger]="_getHostElement()"
6-
[matRippleAnimation]="(disableRipple || disabled || _noopAnimations) ? {} : _rippleAnimation">
5+
[matRippleTrigger]="_getHostElement()">
76
</div>
87
<svg
98
*ngIf="_triggersSubmenu"

src/material-experimental/mdc-menu/menu-item.ts

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {
10-
Component,
11-
ChangeDetectionStrategy,
12-
ViewEncapsulation,
13-
Inject,
14-
ElementRef,
15-
Optional,
16-
ChangeDetectorRef,
17-
} from '@angular/core';
18-
import {
19-
MAT_RIPPLE_GLOBAL_OPTIONS,
20-
RippleAnimationConfig,
21-
RippleGlobalOptions,
22-
} from '@angular/material-experimental/mdc-core';
23-
import {MatMenuItem as BaseMatMenuItem, MatMenuPanel, MAT_MENU_PANEL} from '@angular/material/menu';
24-
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
25-
import {FocusMonitor} from '@angular/cdk/a11y';
26-
import {DOCUMENT} from '@angular/common';
27-
import {numbers} from '@material/ripple';
9+
import {Component, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
10+
import {MatMenuItem as BaseMatMenuItem} from '@angular/material/menu';
2811

2912
/**
3013
* Single item inside of a `mat-menu`. Provides the menu item styling and accessibility treatment.
@@ -53,24 +36,4 @@ import {numbers} from '@material/ripple';
5336
{provide: BaseMatMenuItem, useExisting: MatMenuItem},
5437
]
5538
})
56-
export class MatMenuItem extends BaseMatMenuItem {
57-
_rippleAnimation: RippleAnimationConfig;
58-
_noopAnimations: boolean;
59-
60-
constructor(elementRef: ElementRef<HTMLElement>,
61-
@Inject(DOCUMENT) document?: any,
62-
focusMonitor?: FocusMonitor,
63-
@Inject(MAT_MENU_PANEL) @Optional() parentMenu?: MatMenuPanel<unknown>,
64-
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS)
65-
globalRippleOptions?: RippleGlobalOptions,
66-
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string,
67-
changeDetectorRef?: ChangeDetectorRef) {
68-
super(elementRef, document, focusMonitor, parentMenu, changeDetectorRef);
69-
70-
this._noopAnimations = animationMode === 'NoopAnimations';
71-
this._rippleAnimation = globalRippleOptions?.animation || {
72-
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
73-
exitDuration: numbers.FG_DEACTIVATION_MS
74-
};
75-
}
76-
}
39+
export class MatMenuItem extends BaseMatMenuItem {}

src/material-experimental/mdc-radio/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ng_module(
2626
"//src/material/radio",
2727
"@npm//@angular/forms",
2828
"@npm//@material/radio",
29-
"@npm//@material/ripple",
3029
],
3130
)
3231

src/material-experimental/mdc-radio/radio.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
<div mat-ripple class="mat-radio-ripple mat-mdc-focus-indicator"
2424
[matRippleTrigger]="formField"
2525
[matRippleDisabled]="_isRippleDisabled()"
26-
[matRippleCentered]="true"
27-
[matRippleAnimation]="_rippleAnimation">
26+
[matRippleCentered]="true">
2827
<div class="mat-ripple-element mat-radio-persistent-ripple"></div>
2928
</div>
3029
</div>

src/material-experimental/mdc-radio/radio.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import {FocusMonitor} from '@angular/cdk/a11y';
3434
import {UniqueSelectionDispatcher} from '@angular/cdk/collections';
3535
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
3636
import {NG_VALUE_ACCESSOR} from '@angular/forms';
37-
import {RippleAnimationConfig} from '@angular/material-experimental/mdc-core';
38-
import {numbers} from '@material/ripple';
3937

4038
// Re-export symbols used by the base Material radio component so that users do not need to depend
4139
// on both packages.
@@ -60,12 +58,6 @@ export const MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any = {
6058
export const MAT_RADIO_GROUP =
6159
new InjectionToken<_MatRadioGroupBase<_MatRadioButtonBase>>('MatRadioGroup');
6260

63-
/** Configuration for the ripple animation. */
64-
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
65-
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
66-
exitDuration: numbers.FG_DEACTIVATION_MS
67-
};
68-
6961
/**
7062
* A group of radio buttons. May contain one or more `<mat-radio-button>` elements.
7163
*/
@@ -126,9 +118,6 @@ export class MatRadioButton extends _MatRadioButtonBase implements AfterViewInit
126118
},
127119
};
128120

129-
/** Configuration for the underlying ripple. */
130-
_rippleAnimation: RippleAnimationConfig;
131-
132121
_radioFoundation = new MDCRadioFoundation(this._radioAdapter);
133122
_classes: {[key: string]: boolean} = {};
134123

@@ -143,8 +132,6 @@ export class MatRadioButton extends _MatRadioButtonBase implements AfterViewInit
143132
@Attribute('tabindex') tabIndex?: string) {
144133
super(radioGroup, elementRef, _changeDetector, _focusMonitor,
145134
_radioDispatcher, animationMode, _providerOverride, tabIndex);
146-
this._rippleAnimation =
147-
this._noopAnimations ? {enterDuration: 0, exitDuration: 0} : RIPPLE_ANIMATION_CONFIG;
148135
}
149136

150137
override ngAfterViewInit() {

src/material-experimental/mdc-slide-toggle/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ ng_module(
2929
"@npm//@angular/common",
3030
"@npm//@angular/core",
3131
"@npm//@angular/forms",
32-
"@npm//@material/ripple",
3332
"@npm//@material/switch",
3433
],
3534
)

src/material-experimental/mdc-slide-toggle/slide-toggle.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
<div class="mat-mdc-slide-toggle-ripple mat-mdc-focus-indicator" mat-ripple
2727
[matRippleTrigger]="switch"
2828
[matRippleDisabled]="disableRipple || disabled"
29-
[matRippleCentered]="true"
30-
[matRippleAnimation]="_rippleAnimation"></div>
29+
[matRippleCentered]="true"></div>
3130
</div>
3231
<div class="mdc-switch__icons">
3332
<svg class="mdc-switch__icon mdc-switch__icon--on" viewBox="0 0 24 24">

0 commit comments

Comments
 (0)