feat: allow disable tabs inkBar animation (#5450)

* fix issue [5089](https://github.com/ant-design/ant-design/issues/5089)

* tabs doc
This commit is contained in:
Xie Guanglei 2017-03-24 14:28:11 +08:00 committed by Benjy Cui
parent 583ed547e9
commit b054a0c2b8
4 changed files with 15 additions and 5 deletions

View File

@ -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` | boolean \| {inkBar:boolean, tabPane:boolean} | true |
### Tabs.TabPane
| Property | Description | Type | Default |

View File

@ -28,7 +28,7 @@ export interface TabsProps {
style?: React.CSSProperties;
prefixCls?: string;
className?: string;
animated?: boolean;
animated?: boolean | { inkBar: boolean; tabPane: boolean; };
}
// Tabs
@ -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.'
@ -153,6 +160,7 @@ export default class Tabs extends React.Component<TabsProps, any> {
const renderTabBar = () => (
<ScrollableInkTabBar
inkBarAnimated={inkBarAnimated}
extraContent={tabBarExtraContent}
onTabClick={onTabClick}
onPrevClick={onPrevClick}
@ -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}

View File

@ -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` 时有效 | boolean \| {inkBar:boolean, tabPane:boolean} | true |
### Tabs.TabPane

View File

@ -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 {