Skip to content

Commit

Permalink
fix issue [5089](ant-design#5089)
Browse files Browse the repository at this point in the history
  • Loading branch information
guanglei.xiegl committed Mar 23, 2017
1 parent 9a0b9ad commit 69b3065
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/tabs/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Ant Design has 3 types Tabs for different situation.
| tabPosition | Position of tabs. Options: top, right, bottom & left | string | top |
| onEdit | Callback when tab is added or removed, which is executing when set type as editable-card | (targetKey, action): void | - |
| hideAdd | Hide plus icon or not, which is effective when set type as editable-card | boolean | false |
| animated | Whether to change tabs with animation, this property only works with `tabPosition=top|bottom` | boolean | true |
| animated | Whether to change tabs with animation, this property only works with `tabPosition=top|bottom`. An {inkBar:boolean, tabPane:boolean} object is also allowed | boolean | true |

### Tabs.TabPane
| Property | Description | Type | Default |
Expand Down
12 changes: 10 additions & 2 deletions components/tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface TabsProps {
style?: React.CSSProperties;
prefixCls?: string;
className?: string;
animated?: boolean;
animated?: boolean | { inkBar: boolean; tabPane: boolean; };
}

// Tabs
Expand Down Expand Up @@ -100,6 +100,13 @@ export default class Tabs extends React.Component<TabsProps, any> {
onNextClick,
animated,
} = this.props;

let {inkBarAnimated, tabPaneAnimated} = typeof animated === 'object' ? {
inkBarAnimated: animated.inkBar, tabPaneAnimated: animated.tabPane,
} : {
inkBarAnimated: animated, tabPaneAnimated: animated,
};

warning(
!(type.indexOf('card') >= 0 && size === 'small'),
'Tabs[type=card|editable-card] doesn\'t have small size, it\'s by designed.'
Expand Down Expand Up @@ -153,6 +160,7 @@ export default class Tabs extends React.Component<TabsProps, any> {

const renderTabBar = () => (
<ScrollableInkTabBar
inkBarAnimated={inkBarAnimated}
extraContent={tabBarExtraContent}
onTabClick={onTabClick}
onPrevClick={onPrevClick}
Expand All @@ -167,7 +175,7 @@ export default class Tabs extends React.Component<TabsProps, any> {
className={cls}
tabBarPosition={tabPosition}
renderTabBar={renderTabBar}
renderTabContent={() => <TabContent animated={animated} animatedWithMargin />}
renderTabContent={() => <TabContent animated={tabPaneAnimated} animatedWithMargin />}
onChange={this.handleChange}
>
{childrenWithClose || children}
Expand Down
2 changes: 1 addition & 1 deletion components/tabs/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Ant Design 依次提供了三级选项卡,分别用于不同的场景。
| tabPosition | 页签位置,可选值有 `top` `right` `bottom` `left` | string | 'top' |
| onEdit | 新增和删除页签的回调,在 `type="editable-card"` 时有效 | (targetKey, action): void ||
| hideAdd | 是否隐藏加号图标,在 `type="editable-card"` 时有效 | boolean | false |
| animated | 是否使用动画切换 Tabs,在 `tabPosition=top|bottom` 时有效 | boolean | true |
| animated | 是否使用动画切换 Tabs,在 `tabPosition=top|bottom` 时有效,,也可传入 {inkBar:boolean, tabPane:boolean} 分别控制 | boolean | true |

### Tabs.TabPane

Expand Down
4 changes: 3 additions & 1 deletion components/tabs/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
box-sizing: border-box;
height: 2px;
background-color: @primary-color;
transition: transform 0.3s @ease-in-out;
transform-origin: 0 0;
&-animated {
transition: transform 0.3s @ease-in-out;
}
}

&-bar {
Expand Down

0 comments on commit 69b3065

Please sign in to comment.