Skip to content

Commit cb0ead3

Browse files
devversionjosephperrott
authored andcommitted
docs(ripple): add note about NoopAnimationsModule (#11909)
1 parent 4166d16 commit cb0ead3

File tree

3 files changed

+50
-33
lines changed

3 files changed

+50
-33
lines changed

src/demo-app/toolbar/toolbar-demo.html

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@
2828
<span>Primary Toolbar</span>
2929
<span class="demo-fill-remaining"></span>
3030

31-
<mat-form-field>
32-
<mat-label>Select</mat-label>
33-
<mat-select>
34-
<mat-option value="1">One</mat-option>
35-
<mat-option value="2">Two</mat-option>
36-
</mat-select>
37-
</mat-form-field>
38-
39-
<mat-form-field appearance="legacy">
40-
<mat-label>Input</mat-label>
41-
<input matInput>
42-
</mat-form-field>
43-
4431
<button mat-raised-button>Text</button>
4532
<button mat-raised-button color="accent">Accent</button>
4633
<button mat-stroked-button>Stroked</button>
@@ -56,19 +43,6 @@
5643
<span>Accent Toolbar</span>
5744
<span class="demo-fill-remaining"></span>
5845

59-
<mat-form-field>
60-
<mat-label>Select</mat-label>
61-
<mat-select>
62-
<mat-option value="1">One</mat-option>
63-
<mat-option value="2">Two</mat-option>
64-
</mat-select>
65-
</mat-form-field>
66-
67-
<mat-form-field appearance="legacy">
68-
<mat-label>Input</mat-label>
69-
<input matInput>
70-
</mat-form-field>
71-
7246
<button mat-button>Text</button>
7347
<button mat-flat-button>Flat</button>
7448
<button mat-mini-fab color="">
@@ -111,4 +85,40 @@
11185
</mat-toolbar-row>
11286
</mat-toolbar>
11387
</p>
88+
89+
<h3>Toolbar with form-fields</h3>
90+
91+
<p>
92+
<mat-toolbar>
93+
<mat-form-field>
94+
<mat-label>Select</mat-label>
95+
<mat-select>
96+
<mat-option value="1">One</mat-option>
97+
<mat-option value="2">Two</mat-option>
98+
</mat-select>
99+
</mat-form-field>
100+
101+
<mat-form-field appearance="legacy">
102+
<mat-label>Input</mat-label>
103+
<input matInput>
104+
</mat-form-field>
105+
</mat-toolbar>
106+
</p>
107+
108+
<p>
109+
<mat-toolbar color="primary">
110+
<mat-form-field>
111+
<mat-label>Select</mat-label>
112+
<mat-select>
113+
<mat-option value="1">One</mat-option>
114+
<mat-option value="2">Two</mat-option>
115+
</mat-select>
116+
</mat-form-field>
117+
118+
<mat-form-field appearance="legacy">
119+
<mat-label>Input</mat-label>
120+
<input matInput>
121+
</mat-form-field>
122+
</mat-toolbar>
123+
</p>
114124
</div>

src/lib/core/ripple/ripple.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ const globalRippleConfig: RippleGlobalOptions = {
118118
};
119119
```
120120

121+
**Note**: Ripples will also have no animation if the `NoopAnimationsModule` is being used. This
122+
also means that the durations in the `animation` configuration won't be taken into account.
123+
121124
### Animation behavior
122125

123126
There are two different animation behaviors for the fade-out of ripples shown in the Material

src/lib/core/ripple/ripple.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ export interface RippleGlobalOptions {
3131
disabled?: boolean;
3232

3333
/**
34-
* Configuration for the animation duration of the ripples.
35-
* There are two phases with different durations for the ripples.
34+
* Configuration for the animation duration of the ripples. There are two phases with different
35+
* durations for the ripples. The animation durations will be overwritten if the
36+
* `NoopAnimationsModule` is being used.
3637
*/
3738
animation?: RippleAnimationConfig;
3839

@@ -96,7 +97,8 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget {
9697

9798
/**
9899
* Configuration for the ripple animation. Allows modifying the enter and exit animation
99-
* duration of the ripples.
100+
* duration of the ripples. The animation durations will be overwritten if the
101+
* `NoopAnimationsModule` is being used.
100102
*/
101103
@Input('matRippleAnimation') animation: RippleAnimationConfig;
102104

@@ -137,10 +139,14 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget {
137139
ngZone: NgZone,
138140
platform: Platform,
139141
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions,
140-
@Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string) {
142+
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
141143

142144
this._globalOptions = globalOptions || {};
143145
this._rippleRenderer = new RippleRenderer(this, ngZone, _elementRef, platform);
146+
147+
if (animationMode === 'NoopAnimations') {
148+
this._globalOptions.animation = {enterDuration: 0, exitDuration: 0};
149+
}
144150
}
145151

146152
ngOnInit() {
@@ -163,9 +169,7 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget {
163169
centered: this.centered,
164170
radius: this.radius,
165171
color: this.color,
166-
animation: this._animationMode === 'NoopAnimations' ?
167-
{enterDuration: 0, exitDuration: 0} :
168-
{...this._globalOptions.animation, ...this.animation},
172+
animation: {...this._globalOptions.animation, ...this.animation},
169173
terminateOnPointerUp: this._globalOptions.terminateOnPointerUp,
170174
speedFactor: this.speedFactor * (this._globalOptions.baseSpeedFactor || 1),
171175
};

0 commit comments

Comments
 (0)