+
+
Content of third tab
diff --git a/components/tabs/demo/vertical.ts b/components/tabs/demo/vertical.ts
index 54eec81b..739f25dc 100644
--- a/components/tabs/demo/vertical.ts
+++ b/components/tabs/demo/vertical.ts
@@ -3,36 +3,30 @@ import { Component } from '@angular/core';
@Component({
selector: 'demo-tabs-vertical',
template: `
-
-
-
- Content of first tab
-
-
-
-
- Content of second tab
-
-
-
-
- Content of third tab
-
-
-
+
+
+
+ Content of first tab
+
+
+
+
+ Content of second tab
+
+
+
+
+ Content of third tab
+
+
+
`,
styles: [
`
diff --git a/components/tabs/doc/index.en-US.md b/components/tabs/doc/index.en-US.md
index 6016267b..df7257d6 100644
--- a/components/tabs/doc/index.en-US.md
+++ b/components/tabs/doc/index.en-US.md
@@ -28,6 +28,7 @@ animated | Whether to change tabs with animation | boolean | true | false
onChange | Callback when tab is switched | (index: number) => void |
| false
onTabClick | on tab click | (index: number) => void |
| false
distanceToChangeTab | distance to change tab, width ratio | number | 0.3 | false
+| prerenderingSiblingsNumber| pre-render nearby sibling, -1: render all the siblings, 0: render current page | number | 1 |
tabDirection | tab paging direction | 'horizontal' \| 'vertical' | horizontal | false
tabBarUnderlineStyle | style of the default tab bar's underline | object |
| false
tabBarBackgroundColor | color of the default tab bar's background | string |
| false
diff --git a/components/tabs/doc/index.zh-CN.md b/components/tabs/doc/index.zh-CN.md
index 86dd6ce3..d3c6a370 100644
--- a/components/tabs/doc/index.zh-CN.md
+++ b/components/tabs/doc/index.zh-CN.md
@@ -28,6 +28,7 @@ animated | 是否开启切换动画 | boolean | true | false
onChange | tab变化时触发 | (index: number) => void |
| false
onTabClick | tab 被点击的回调 | (index: number) => void |
| false
distanceToChangeTab | 滑动切换阈值(宽度比例) | number | 0.3 | false
+| prerenderingSiblingsNumber| 预加载相邻的tab内容, -1: 加载所有的tab内容, 0: 仅加载当前tab内容 | number | 1 |
tabDirection | Tab方向 | 'horizontal' \| 'vertical' | horizontal | false
tabBarUnderlineStyle | tabBar下划线样式 | object |
| false
tabBarBackgroundColor | tabBar背景色 | string |
| false
diff --git a/components/tabs/public-api.ts b/components/tabs/public-api.ts
index 3df8f93a..38fb60c7 100644
--- a/components/tabs/public-api.ts
+++ b/components/tabs/public-api.ts
@@ -1,4 +1,5 @@
export * from './tabs.module';
export * from './tabs.component';
export * from './tab-pane.component';
+export * from './tab-pane-body.component';
export * from './default-tab-bar.component';
diff --git a/components/tabs/style/addon.less b/components/tabs/style/addon.less
index ec958dad..31014fe7 100644
--- a/components/tabs/style/addon.less
+++ b/components/tabs/style/addon.less
@@ -6,22 +6,53 @@
.@{tabs-prefix-cls} {
&-pane-wrap {
- position: absolute;
- top: 0;
- left: 0;
- }
- &-pane-wrap:first-child {
- position: relative;
+ touch-action: pan-x pan-y;
}
}
-.@{tabs-default-bar-prefix-cls}-top,
-.@{tabs-default-bar-prefix-cls}-bottom {
- .@{tabs-default-bar-prefix-cls}-underline {
- left: 0;
+.@{tabs-default-bar-prefix-cls} {
+ &-top,
+ &-bottom {
+ &-underline {
+ left: 0;
+ }
+ }
+
+ &-top {
+ border-bottom: 1px solid rgba(217, 217, 217, 0.5);
+ .@{tabs-default-bar-prefix-cls} {
+ &-tab::after {
+ height: 0 !important;
+ }
+ }
+ }
+ &-bottom {
+ border-top: 1px solid rgba(217, 217, 217, 0.5);
+ .@{tabs-default-bar-prefix-cls} {
+ &-tab::before {
+ height: 0 !important;
+ }
+ }
+ }
+ &-left {
+ border-right: 1px solid rgba(217, 217, 217, 0.5);
+ .@{tabs-default-bar-prefix-cls} {
+ &-tab::after {
+ width: 0 !important;
+ }
+ }
+ }
+ &-right {
+ border-left: 1px solid rgba(217, 217, 217, 0.5);
+ .@{tabs-default-bar-prefix-cls} {
+ &-tab::before {
+ width: 0 !important;
+ }
+ }
}
}
+
.@{tabs-default-bar-prefix-cls}-left,
.@{tabs-default-bar-prefix-cls}-right {
.@{tabs-default-bar-prefix-cls}-underline {
diff --git a/components/tabs/style/index.less b/components/tabs/style/index.less
index 2babed46..6306a6f5 100644
--- a/components/tabs/style/index.less
+++ b/components/tabs/style/index.less
@@ -39,6 +39,7 @@
flex: 1;
width: 100%;
height: 100%;
+ min-height: 0;
&-animated {
transition: transform @effect-duration @easing-in-out, left @effect-duration @easing-in-out, top @effect-duration @easing-in-out;
diff --git a/components/tabs/tab-pane-body.component.html b/components/tabs/tab-pane-body.component.html
new file mode 100644
index 00000000..c9cf5dee
--- /dev/null
+++ b/components/tabs/tab-pane-body.component.html
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/components/tabs/tab-pane-body.component.ts b/components/tabs/tab-pane-body.component.ts
new file mode 100644
index 00000000..b47b8597
--- /dev/null
+++ b/components/tabs/tab-pane-body.component.ts
@@ -0,0 +1,29 @@
+import { Component, OnInit, Input, HostBinding, TemplateRef, ViewEncapsulation } from '@angular/core';
+
+@Component({
+ selector: '[tab-pane-body]',
+ templateUrl: './tab-pane-body.component.html',
+ encapsulation: ViewEncapsulation.None
+})
+export class TabPaneBody implements OnInit {
+
+ @Input() active: boolean = false;
+ @Input() hidden: boolean = false;
+ @Input() content: TemplateRef
;
+
+ @HostBinding('class.am-tabs-pane-wrap')
+ paneWrap: boolean = true;
+ @HostBinding('class.am-tabs-pane-wrap-active')
+ get wrapActive(): boolean {
+ return this.active;
+ }
+ @HostBinding('class.am-tabs-pane-wrap-inactive')
+ get wrapInactive(): boolean {
+ return !this.active;
+ }
+
+ constructor() { }
+
+ ngOnInit() { }
+
+}
diff --git a/components/tabs/tab-pane.component.html b/components/tabs/tab-pane.component.html
index f16322a0..b06f3d0f 100644
--- a/components/tabs/tab-pane.component.html
+++ b/components/tabs/tab-pane.component.html
@@ -1 +1,3 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/components/tabs/tab-pane.component.ts b/components/tabs/tab-pane.component.ts
index d5ca50b6..2ea64bdf 100644
--- a/components/tabs/tab-pane.component.ts
+++ b/components/tabs/tab-pane.component.ts
@@ -1,120 +1,17 @@
-import { Component, Input, HostBinding, TemplateRef } from '@angular/core';
-import { trigger, state, style } from '@angular/animations';
-
-export type TabPanelPositionState =
- | 'center-with-animation'
- | 'center-without-animation'
- | 'top-with-animation'
- | 'top-with-animation-with-higher-zindex'
- | 'top-without-animation'
- | 'left-with-animation'
- | 'left-with-animation-with-higher-zindex'
- | 'left-without-animation'
- | 'bottom-with-animation'
- | 'bottom-with-animation-with-higher-zindex'
- | 'bottom-without-animation'
- | 'right-with-animation'
- | 'right-with-animation-with-higher-zindex'
- | 'right-without-animation';
+import { Component, Input, ViewChild, TemplateRef } from '@angular/core';
@Component({
selector: 'TabPane, nzm-tab-pane',
- templateUrl: './tab-pane.component.html',
- styles: [`:host {touch-action: auto}`],
- host: {
- '[@translateTabPane]': 'position',
- '(@translateTabPane.start)': 'onTranslateTabStarted($event)',
- '(@translateTabPane.done)': 'onTranslateTabComplete($event)'
- },
- animations: [
- trigger('translateTabPane', [
- state(
- 'left-with-animation',
- style({
- transform: 'translate3d(-100%, 0, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state(
- 'left-with-animation-with-higher-zindex',
- style({
- 'z-index': 100,
- transform: 'translate3d(-100%, 0, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state('left-without-animation', style({transform: 'translate3d(-100%, 0, 0)' })),
- state(
- 'right-with-animation',
- style({
- transform: 'translate3d(100%, 0, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state(
- 'right-with-animation-with-higher-zindex',
- style({
- 'z-index': 100,
- transform: 'translate3d(100%, 0, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state('right-without-animation', style({transform: 'translate3d(100%, 0, 0)' })),
- state(
- 'top-with-animation',
- style({
- transform: 'translate3d(0, -100%, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state(
- 'top-with-animation-with-higher-zindex',
- style({
- 'z-index': 100,
- transform: 'translate3d(0, -100%, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state('top-without-animation', style({ transform: 'translate3d(0, -100%, 0)' })),
- state(
- 'bottom-with-animation',
- style({
- transform: 'translate3d(0, 100%, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state(
- 'bottom-with-animation-with-higher-zindex',
- style({
- 'z-index': 100,
- transform: 'translate3d(0, 100%, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state('bottom-without-animation', style({ transform: 'translate3d(0, 100%, 0)' })),
- state(
- 'center-with-animation',
- style({
- 'z-index': 100,
- transform: 'translate3d(0, 0, 0)',
- transition: '.3s cubic-bezier(0.35, 0, 0.25, 1)'
- })
- ),
- state('center-without-animation', style({ transform: 'translate3d(0, 0, 0)' }))
- ])
- ]
+ templateUrl: './tab-pane.component.html'
})
export class TabPane {
- prefixCls: string = 'am-tabs-pane';
- tintColor: string = '#108ee9';
- unselectedTintColor: string = '#888';
- active: boolean = true;
- isTitleString: boolean = true;
- showTabPanelContent: boolean = false;
- position: TabPanelPositionState;
+
+ public isTitleString: boolean = true;
private _title: string | TemplateRef;
+ @ViewChild('content') content: TemplateRef;
+
@Input()
get title(): string | TemplateRef {
return this._title;
@@ -124,54 +21,6 @@ export class TabPane {
this._title = value;
}
- @HostBinding('class.am-tabs-pane-wrap')
- paneWrap: boolean = true;
- @HostBinding('class.am-tabs-pane-wrap-active')
- get wrapActive(): boolean {
- return this.active;
- }
- @HostBinding('class.am-tabs-pane-wrap-inactive')
- get wrapInactive(): boolean {
- return !this.active;
- }
-
constructor() {}
- onTranslateTabStarted(e: any) {
- if (
- (e.toState == 'center-with-animation' ||
- e.toState == 'center-without-animation' ||
- e.toState == 'left-with-animation-with-higher-zindex' ||
- e.toState == 'right-with-animation-with-higher-zindex' ||
- e.toState == 'top-with-animation-with-higher-zindex' ||
- e.toState == 'bottom-with-animation-with-higher-zindex') &&
- (this.position == 'center-with-animation' ||
- this.position == 'center-without-animation' ||
- this.position == 'left-with-animation-with-higher-zindex' ||
- this.position == 'right-with-animation-with-higher-zindex' ||
- this.position == 'top-with-animation-with-higher-zindex' ||
- this.position == 'bottom-with-animation-with-higher-zindex')
- ) {
- this.showTabPanelContent = true;
- }
- }
-
- onTranslateTabComplete(e: any) {
- if (
- e.toState !== 'center-with-animation' &&
- e.toState !== 'center-without-animation' &&
- e.toState !== 'left-with-animation-with-higher-zindex' &&
- e.toState !== 'right-with-animation-with-higher-zindex' &&
- e.toState !== 'top-with-animation-with-higher-zindex' &&
- e.toState !== 'bottom-with-animation-with-higher-zindex' &&
- this.position !== 'center-with-animation' &&
- this.position !== 'center-without-animation' &&
- this.position !== 'left-with-animation-with-higher-zindex' &&
- this.position !== 'right-with-animation-with-higher-zindex' &&
- this.position !== 'top-with-animation-with-higher-zindex' &&
- this.position !== 'bottom-with-animation-with-higher-zindex'
- ) {
- this.showTabPanelContent = false;
- }
- }
}
diff --git a/components/tabs/tabs.component.html b/components/tabs/tabs.component.html
index 8a9cb873..a20e8666 100644
--- a/components/tabs/tabs.component.html
+++ b/components/tabs/tabs.component.html
@@ -10,7 +10,12 @@
(touchmove)="onTouchMove($event)"
(touchend)="onTouchEnd($event)"
>
-
+ = 0 && ((selectedKey - i > prerenderingSiblingsNumber) || (selectedKey - i + prerenderingSiblingsNumber < 0 ))"
+ [content]="tabPane.content"
+ >