feat: allow disable tabs inkBar animation (#5450)

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

* tabs doc
pull/5461/merge
Xie Guanglei 8 years ago committed by Benjy Cui
parent 583ed547e9
commit b054a0c2b8

@ -33,7 +33,7 @@ Ant Design has 3 types Tabs for different situation.
| tabPosition | Position of tabs. Options: top, right, bottom & left | string | top | | 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 | - | | 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 | | 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 ### Tabs.TabPane
| Property | Description | Type | Default | | Property | Description | Type | Default |

@ -28,7 +28,7 @@ export interface TabsProps {
style?: React.CSSProperties; style?: React.CSSProperties;
prefixCls?: string; prefixCls?: string;
className?: string; className?: string;
animated?: boolean; animated?: boolean | { inkBar: boolean; tabPane: boolean; };
} }
// Tabs // Tabs
@ -100,6 +100,13 @@ export default class Tabs extends React.Component<TabsProps, any> {
onNextClick, onNextClick,
animated, animated,
} = this.props; } = this.props;
let {inkBarAnimated, tabPaneAnimated} = typeof animated === 'object' ? {
inkBarAnimated: animated.inkBar, tabPaneAnimated: animated.tabPane,
} : {
inkBarAnimated: animated, tabPaneAnimated: animated,
};
warning( warning(
!(type.indexOf('card') >= 0 && size === 'small'), !(type.indexOf('card') >= 0 && size === 'small'),
'Tabs[type=card|editable-card] doesn\'t have small size, it\'s by designed.' '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 = () => ( const renderTabBar = () => (
<ScrollableInkTabBar <ScrollableInkTabBar
inkBarAnimated={inkBarAnimated}
extraContent={tabBarExtraContent} extraContent={tabBarExtraContent}
onTabClick={onTabClick} onTabClick={onTabClick}
onPrevClick={onPrevClick} onPrevClick={onPrevClick}
@ -167,7 +175,7 @@ export default class Tabs extends React.Component<TabsProps, any> {
className={cls} className={cls}
tabBarPosition={tabPosition} tabBarPosition={tabPosition}
renderTabBar={renderTabBar} renderTabBar={renderTabBar}
renderTabContent={() => <TabContent animated={animated} animatedWithMargin />} renderTabContent={() => <TabContent animated={tabPaneAnimated} animatedWithMargin />}
onChange={this.handleChange} onChange={this.handleChange}
> >
{childrenWithClose || children} {childrenWithClose || children}

@ -36,7 +36,7 @@ Ant Design 依次提供了三级选项卡,分别用于不同的场景。
| tabPosition | 页签位置,可选值有 `top` `right` `bottom` `left` | string | 'top' | | tabPosition | 页签位置,可选值有 `top` `right` `bottom` `left` | string | 'top' |
| onEdit | 新增和删除页签的回调,在 `type="editable-card"` 时有效 | (targetKey, action): void | 无 | | onEdit | 新增和删除页签的回调,在 `type="editable-card"` 时有效 | (targetKey, action): void | 无 |
| hideAdd | 是否隐藏加号图标,在 `type="editable-card"` 时有效 | boolean | false | | 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 ### Tabs.TabPane

@ -18,8 +18,10 @@
box-sizing: border-box; box-sizing: border-box;
height: 2px; height: 2px;
background-color: @primary-color; background-color: @primary-color;
transition: transform 0.3s @ease-in-out;
transform-origin: 0 0; transform-origin: 0 0;
&-animated {
transition: transform 0.3s @ease-in-out;
}
} }
&-bar { &-bar {

Loading…
Cancel
Save