Skip to content
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
24 changes: 24 additions & 0 deletions src/lib/core/ripple/ripple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {defaultRippleAnimationConfig, RippleAnimationConfig} from './ripple-rend
import {
MatRipple, MatRippleModule, MAT_RIPPLE_GLOBAL_OPTIONS, RippleState, RippleGlobalOptions
} from './index';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';

/** Shorthands for the enter and exit duration of ripples. */
const {enterDuration, exitDuration} = defaultRippleAnimationConfig;
Expand Down Expand Up @@ -553,6 +554,29 @@ describe('MatRipple', () => {
}));
});

describe('with disabled animations', () => {
let rippleDirective: MatRipple;

beforeEach(() => {
TestBed.resetTestingModule();
TestBed.configureTestingModule({
imports: [NoopAnimationsModule, MatRippleModule],
declarations: [BasicRippleContainer],
});

fixture = TestBed.createComponent(BasicRippleContainer);
fixture.detectChanges();

rippleTarget = fixture.nativeElement.querySelector('[mat-ripple]');
rippleDirective = fixture.componentInstance.ripple;
});

it('should set the animation durations to zero', () => {
expect(rippleDirective.rippleConfig.animation!.enterDuration).toBe(0);
expect(rippleDirective.rippleConfig.animation!.exitDuration).toBe(0);
});
});

describe('configuring behavior', () => {
let controller: RippleContainerWithInputBindings;

Expand Down
8 changes: 6 additions & 2 deletions src/lib/core/ripple/ripple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from '@angular/core';
import {RippleRef} from './ripple-ref';
import {RippleAnimationConfig, RippleConfig, RippleRenderer, RippleTarget} from './ripple-renderer';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';

/** Configurable options for `matRipple`. */
export interface RippleGlobalOptions {
Expand Down Expand Up @@ -135,7 +136,8 @@ export class MatRipple implements OnInit, OnDestroy, RippleTarget {
constructor(private _elementRef: ElementRef,
ngZone: NgZone,
platform: Platform,
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions) {
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions,
@Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string) {

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