Skip to content

Commit dfbf3a5

Browse files
committed
fix(ripple): disable ripple animations when using NoopAnimationsModule
Disables the ripples animations when the consumer is using the `NoopAnimationsModule`.
1 parent 81b6a78 commit dfbf3a5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/core/ripple/ripple.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from '@angular/core';
2121
import {RippleRef} from './ripple-ref';
2222
import {RippleAnimationConfig, RippleConfig, RippleRenderer, RippleTarget} from './ripple-renderer';
23+
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
2324

2425
/** Configurable options for `matRipple`. */
2526
export interface RippleGlobalOptions {
@@ -135,7 +136,8 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget {
135136
constructor(private _elementRef: ElementRef,
136137
ngZone: NgZone,
137138
platform: Platform,
138-
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions) {
139+
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions,
140+
@Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string) {
139141

140142
this._globalOptions = globalOptions || {};
141143
this._rippleRenderer = new RippleRenderer(this, ngZone, _elementRef, platform);
@@ -161,7 +163,9 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget {
161163
centered: this.centered,
162164
radius: this.radius,
163165
color: this.color,
164-
animation: {...this._globalOptions.animation, ...this.animation},
166+
animation: this._animationMode === 'NoopAnimations' ?
167+
{enterDuration: 0, exitDuration: 0} :
168+
{...this._globalOptions.animation, ...this.animation},
165169
terminateOnPointerUp: this._globalOptions.terminateOnPointerUp,
166170
speedFactor: this.speedFactor * (this._globalOptions.baseSpeedFactor || 1),
167171
};

0 commit comments

Comments
 (0)