Skip to content

Commit

Permalink
fix(tabs): fix placement of tab when value is set in selectedIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Dec 11, 2018
1 parent e12ef53 commit 8489345
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/lib/tabs/tabs.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,27 +348,25 @@ export class LyTabs extends LyTabsMixinBase implements OnChanges, OnInit, AfterV
this._selectedBeforeTab = this._selectedTab;
this.selectedIndexChange.emit(this._selectedIndex);
this._updateIndicator(this._selectedTab, this._selectedBeforeTab);

this._markForCheck();
// const position = this._flexDirection === 'column' ? 'Y' : 'X';
const placement = this.headerPlacement;
this._selectedIndexClass = this._theme.addStyle(`lyTabs.selectedIndex:${index}+${placement}`, (theme: ThemeVariables) => {
let sign = 1;
const position = this._getFlexDirection(placement) === 'column' ? 'Y' : 'X';
if (theme.direction === Dir.ltr || position === 'Y') {
sign = -1;
}
return {
transform: `translate${position}(${index * 100 * sign}%)`
};
}, this.tabContents.nativeElement, this._selectedIndexClass, STYLE_PRIORITY);
Promise.resolve(null).then(() => {
const placement = this.headerPlacement;
this._selectedIndexClass = this._theme.addStyle(`lyTabs.selectedIndex:${index}+${placement}`, (theme: ThemeVariables) => {
let sign = 1;
const position = this._getFlexDirection(placement) === 'column' ? 'Y' : 'X';
if (theme.direction === Dir.ltr || position === 'Y') {
sign = -1;
}
return {
transform: `translate${position}(${index * 100 * sign}%)`
};
}, this.tabContents.nativeElement, this._selectedIndexClass, STYLE_PRIORITY);
this.renderer.addClass(this.tabContents.nativeElement, this._selectedIndexClass);
});
}
}
get selectedIndex() {
return this._selectedIndex as number;
return this._selectedIndex;
}

@Output() selectedIndexChange: EventEmitter<any> = new EventEmitter();
Expand Down

0 comments on commit 8489345

Please sign in to comment.