Skip to content

Commit

Permalink
feat(tabs): add animation done event #5238 (#6811)
Browse files Browse the repository at this point in the history
* feat(tabs): add animation done event #5238

* chore(test): add test

* chore(tests): remove fit
  • Loading branch information
amcdnl authored and andrewseguin committed Dec 13, 2017
1 parent a411382 commit 3a52624
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib/tabs/tab-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ describe('MatTabGroup', () => {
expect(tabs[1].isActive).toBe(false);
expect(tabs[2].isActive).toBe(true);
});

it('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', () => {
Expand Down Expand Up @@ -430,6 +442,7 @@ describe('nested MatTabGroup with enabled animations', () => {
[(selectedIndex)]="selectedIndex"
[headerPosition]="headerPosition"
[disableRipple]="disableRipple"
(animationDone)="animationDone()"
(focusChange)="handleFocus($event)"
(selectedTabChange)="handleSelection($event)">
<mat-tab>
Expand Down Expand Up @@ -460,6 +473,7 @@ class SimpleTabsTestApp {
handleSelection(event: any) {
this.selectEvent = event;
}
animationDone() { }
}

@Component({
Expand Down
4 changes: 4 additions & 0 deletions src/lib/tabs/tab-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentIn
/** Event emitted when focus has changed within a tab group. */
@Output() focusChange: EventEmitter<MatTabChangeEvent> = new EventEmitter<MatTabChangeEvent>();

/** Event emitted when the body animation has completed */
@Output() animationDone: EventEmitter<void> = new EventEmitter<void>();

/** Event emitted when the tab selection has changed. */
@Output() selectedTabChange: EventEmitter<MatTabChangeEvent> =
new EventEmitter<MatTabChangeEvent>(true);
Expand Down Expand Up @@ -280,6 +283,7 @@ export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentIn
_removeTabBodyWrapperHeight(): void {
this._tabBodyWrapperHeight = this._tabBodyWrapper.nativeElement.clientHeight;
this._tabBodyWrapper.nativeElement.style.height = '';
this.animationDone.emit();
}

/** Handle click events, setting new selected index if appropriate. */
Expand Down

0 comments on commit 3a52624

Please sign in to comment.