From 5bc588a05888c433742eb389ea5c697b9bee27ab Mon Sep 17 00:00:00 2001 From: Austin Date: Sat, 2 Sep 2017 10:42:11 -0500 Subject: [PATCH 1/3] feat(tabs): add animation done event #5238 --- src/lib/tabs/tab-group.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/tabs/tab-group.ts b/src/lib/tabs/tab-group.ts index 8c3bf330cc40..e6b4b91bb362 100644 --- a/src/lib/tabs/tab-group.ts +++ b/src/lib/tabs/tab-group.ts @@ -134,6 +134,9 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit /** Event emitted when focus has changed within a tab group. */ @Output() focusChange: EventEmitter = new EventEmitter(); + /** Event emitted when the body animation has completed */ + @Output() animationDone: EventEmitter = new EventEmitter(); + /** Event emitted when the tab selection has changed. */ @Output() selectChange: EventEmitter = new EventEmitter(true); @@ -269,5 +272,6 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit _removeTabBodyWrapperHeight(): void { this._tabBodyWrapperHeight = this._tabBodyWrapper.nativeElement.clientHeight; this._renderer.setStyle(this._tabBodyWrapper.nativeElement, 'height', ''); + this.animationDone.emit(); } } From 78eeda702e491fbf03425118f88eb997fc2ff7ef Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 3 Oct 2017 11:11:46 -0500 Subject: [PATCH 2/3] chore(test): add test --- src/lib/tabs/tab-group.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/tabs/tab-group.spec.ts b/src/lib/tabs/tab-group.spec.ts index f6c4668c0fb5..38b11444804b 100644 --- a/src/lib/tabs/tab-group.spec.ts +++ b/src/lib/tabs/tab-group.spec.ts @@ -205,6 +205,18 @@ describe('MatTabGroup', () => { expect(tabs[1].isActive).toBe(false); expect(tabs[2].isActive).toBe(true); }); + + fit('should fire animation done event', fakeAsync(() => { + fixture.detectChanges(); + + spyOn(fixture.componentInstance, 'animationDone'); + let tabLabel = fixture.debugElement.queryAll(By.css('.mat-tab-label'))[1]; + tabLabel.nativeElement.click(); + fixture.detectChanges(); + tick(); + + expect(fixture.componentInstance.animationDone).toHaveBeenCalled(); + })); }); describe('disable tabs', () => { @@ -411,6 +423,7 @@ describe('nested MatTabGroup with enabled animations', () => { [(selectedIndex)]="selectedIndex" [headerPosition]="headerPosition" [disableRipple]="disableRipple" + (animationDone)="animationDone()" (focusChange)="handleFocus($event)" (selectChange)="handleSelection($event)"> @@ -441,6 +454,7 @@ class SimpleTabsTestApp { handleSelection(event: any) { this.selectEvent = event; } + animationDone() { } } @Component({ From 619628d3f4121a353eab0774696a3650d4cc348e Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 9 Oct 2017 08:41:33 -0500 Subject: [PATCH 3/3] chore(tests): remove fit --- src/lib/tabs/tab-group.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/tabs/tab-group.spec.ts b/src/lib/tabs/tab-group.spec.ts index 38b11444804b..f5b34db040ec 100644 --- a/src/lib/tabs/tab-group.spec.ts +++ b/src/lib/tabs/tab-group.spec.ts @@ -206,7 +206,7 @@ describe('MatTabGroup', () => { expect(tabs[2].isActive).toBe(true); }); - fit('should fire animation done event', fakeAsync(() => { + it('should fire animation done event', fakeAsync(() => { fixture.detectChanges(); spyOn(fixture.componentInstance, 'animationDone');