Skip to content

docs(ripple): add note about NoopAnimationsModule #11909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 36 additions & 26 deletions src/demo-app/toolbar/toolbar-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@
<span>Primary Toolbar</span>
<span class="demo-fill-remaining"></span>

<mat-form-field>
<mat-label>Select</mat-label>
<mat-select>
<mat-option value="1">One</mat-option>
<mat-option value="2">Two</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="legacy">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>

<button mat-raised-button>Text</button>
<button mat-raised-button color="accent">Accent</button>
<button mat-stroked-button>Stroked</button>
Expand All @@ -56,19 +43,6 @@
<span>Accent Toolbar</span>
<span class="demo-fill-remaining"></span>

<mat-form-field>
<mat-label>Select</mat-label>
<mat-select>
<mat-option value="1">One</mat-option>
<mat-option value="2">Two</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="legacy">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>

<button mat-button>Text</button>
<button mat-flat-button>Flat</button>
<button mat-mini-fab color="">
Expand Down Expand Up @@ -111,4 +85,40 @@
</mat-toolbar-row>
</mat-toolbar>
</p>

<h3>Toolbar with form-fields</h3>

<p>
<mat-toolbar>
<mat-form-field>
<mat-label>Select</mat-label>
<mat-select>
<mat-option value="1">One</mat-option>
<mat-option value="2">Two</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="legacy">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>
</mat-toolbar>
</p>

<p>
<mat-toolbar color="primary">
<mat-form-field>
<mat-label>Select</mat-label>
<mat-select>
<mat-option value="1">One</mat-option>
<mat-option value="2">Two</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="legacy">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>
</mat-toolbar>
</p>
</div>
3 changes: 3 additions & 0 deletions src/lib/core/ripple/ripple.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ const globalRippleConfig: RippleGlobalOptions = {
};
```

**Note**: Ripples will also have no animation if the `NoopAnimationsModule` is being used. This
also means that the durations in the `animation` configuration won't be taken into account.

### Animation behavior

There are two different animation behaviors for the fade-out of ripples shown in the Material
Expand Down
18 changes: 11 additions & 7 deletions src/lib/core/ripple/ripple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ export interface RippleGlobalOptions {
disabled?: boolean;

/**
* Configuration for the animation duration of the ripples.
* There are two phases with different durations for the ripples.
* Configuration for the animation duration of the ripples. There are two phases with different
* durations for the ripples. The animation durations will be overwritten if the
* `NoopAnimationsModule` is being used.
*/
animation?: RippleAnimationConfig;

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

/**
* Configuration for the ripple animation. Allows modifying the enter and exit animation
* duration of the ripples.
* duration of the ripples. The animation durations will be overwritten if the
* `NoopAnimationsModule` is being used.
*/
@Input('matRippleAnimation') animation: RippleAnimationConfig;

Expand Down Expand Up @@ -137,10 +139,14 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget {
ngZone: NgZone,
platform: Platform,
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions,
@Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string) {
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {

this._globalOptions = globalOptions || {};
this._rippleRenderer = new RippleRenderer(this, ngZone, _elementRef, platform);

if (animationMode === 'NoopAnimations') {
this._globalOptions.animation = {enterDuration: 0, exitDuration: 0};
}
}

ngOnInit() {
Expand All @@ -163,9 +169,7 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget {
centered: this.centered,
radius: this.radius,
color: this.color,
animation: this._animationMode === 'NoopAnimations' ?
{enterDuration: 0, exitDuration: 0} :
{...this._globalOptions.animation, ...this.animation},
animation: {...this._globalOptions.animation, ...this.animation},
terminateOnPointerUp: this._globalOptions.terminateOnPointerUp,
speedFactor: this.speedFactor * (this._globalOptions.baseSpeedFactor || 1),
};
Expand Down