Skip to content

Commit

Permalink
fix(tabs): fix height
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Dec 1, 2018
1 parent f044fec commit 45214c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/app/demo-view/view/view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const styles = {
display: 'block'
},
codeContainer: {
maxHeight: '200px',
overflowY: 'auto',
padding: '24px',
height: '100%'
Expand Down
3 changes: 3 additions & 0 deletions src/lib/src/minimal/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class NgTranscludeDirective implements OnDestroy {
if (templateRef) {
this._ngTransclude = templateRef;
this._viewRef.createEmbeddedView(templateRef);
} else {
this._ngTransclude = null;
this._viewRef.clear();
}
}

Expand Down
26 changes: 4 additions & 22 deletions src/lib/tabs/tabs.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ mixinBg(
export class LyTabs extends LyTabsMixinBase implements OnChanges, OnInit, AfterViewInit, AfterContentInit, OnDestroy {
_selectedIndex = 0;
_selectedBeforeIndex: number;
_selectedRequireCheck: boolean;
_selectedTab: LyTab;
_selectedBeforeTab: LyTab;
private _tabsSubscription = Subscription.EMPTY;
Expand Down Expand Up @@ -127,9 +126,7 @@ export class LyTabs extends LyTabsMixinBase implements OnChanges, OnInit, AfterV
this.selectedIndexChange.emit(this._selectedIndex);
this._updateIndicator(this._selectedTab, this._selectedBeforeTab);

if (this._selectedRequireCheck) {
this.markForCheck();
}
this.markForCheck();
this.renderer.setStyle(this.tabContents.nativeElement, 'transform', `translate3d(${this._selectedIndex * -100}%,0,0)`);
}
}
Expand Down Expand Up @@ -235,29 +232,16 @@ export class LyTabs extends LyTabsMixinBase implements OnChanges, OnInit, AfterV
}

loadTemplate(tab: LyTab, index: number): TemplateRef<LyTabContent> | null {
if (tab.loaded) {
return null;
}
tab.index = index;
if (this.selectedIndex === tab.index) {
// set 0 if is null
this._selectedTab = tab;
this._updateIndicator(tab);
} else if (!this._isViewInitLoaded && this.selectedIndex === tab.index) {
this._selectedTab = tab;
/** Apply style for tabIndicator server */
this._updateIndicator(tab);
}
if (tab.templateRefLazy) {
if (this.selectedIndex === index) {
tab.loaded = true;
return tab.templateRefLazy;
} else {
return null;
}
if (this.selectedIndex === tab.index) {
return tab.templateRefLazy || tab.templateRef;
} else {
tab.loaded = true;
return tab.templateRef;
return null;
}
}
}
Expand All @@ -270,13 +254,11 @@ export class LyTabs extends LyTabsMixinBase implements OnChanges, OnInit, AfterV
})
export class LyTab implements OnInit, AfterViewInit {
index: number;
loaded: boolean;
protected readonly classes;
@ContentChild(LyTabContent, { read: TemplateRef }) templateRefLazy: TemplateRef<LyTabContent>;
@ViewChild(TemplateRef) templateRef: TemplateRef<any>;
@ViewChild('tabIndicator') tabIndicator: ElementRef;
@HostListener('click') onClick() {
this.tabs._selectedRequireCheck = !this.loaded;
this.tabs.selectedIndex = this.index;
}

Expand Down

0 comments on commit 45214c6

Please sign in to comment.