diff --git a/packages/platform-browser/animations/src/animation_builder.ts b/packages/platform-browser/animations/src/animation_builder.ts index 057b1b5d55685..74959020dee27 100644 --- a/packages/platform-browser/animations/src/animation_builder.ts +++ b/packages/platform-browser/animations/src/animation_builder.ts @@ -104,6 +104,7 @@ export class RendererAnimationPlayer implements AnimationPlayer { reset(): void { this._command('reset'); + this._started = false; } setPosition(p: number): void { diff --git a/packages/platform-browser/animations/test/browser_animation_builder_spec.ts b/packages/platform-browser/animations/test/browser_animation_builder_spec.ts index 7a45c7d2e9a57..653e8e01be9cb 100644 --- a/packages/platform-browser/animations/test/browser_animation_builder_spec.ts +++ b/packages/platform-browser/animations/test/browser_animation_builder_spec.ts @@ -104,5 +104,40 @@ import {el} from '../../testing/src/browser_util'; expect(finished).toBeTruthy(); expect(destroyed).toBeTruthy(); })); + + it('should check status of start of play and reset', fakeAsync(() => { + @Component({ + selector: 'ani-another-cmp', + template: '...', + }) + class CmpAnother { + @ViewChild('target') public target: any; + + constructor(public builder: AnimationBuilder) {} + + build() { + const definition = + this.builder.build([style({opacity: 0}), animate(1000, style({opacity: 1}))]); + + return definition.create(this.target); + } + } + + TestBed.configureTestingModule({declarations: [CmpAnother]}); + + const fixture = TestBed.createComponent(CmpAnother); + const cmp = fixture.componentInstance; + fixture.detectChanges(); + + const player = cmp.build(); + + player.play(); + flushMicrotasks(); + expect(player.hasStarted).toBeTruthy(); + + player.reset(); + flushMicrotasks(); + expect(player.hasStarted).toBeFalsy(); + })); }); }