update Tabs
updata
This commit is contained in:
parent
17f52abf5b
commit
77bafb3181
4 changed files with 21 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="prefixCls"><slot></slot></div>
|
<div :class="prefixCls" v-show="show"><slot></slot></div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
const prefixCls = 'ivu-tabs-tabpane';
|
const prefixCls = 'ivu-tabs-tabpane';
|
||||||
|
|
|
@ -74,13 +74,17 @@
|
||||||
contentClasses () {
|
contentClasses () {
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-content`,
|
`${prefixCls}-content`,
|
||||||
`${prefixCls}-content-animated`
|
{
|
||||||
|
[`${prefixCls}-content-animated`]: this.animated
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
barClasses () {
|
barClasses () {
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-ink-bar`,
|
`${prefixCls}-ink-bar`,
|
||||||
`${prefixCls}-ink-bar-animated`
|
{
|
||||||
|
[`${prefixCls}-ink-bar-animated`]: this.animated
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
contentStyle () {
|
contentStyle () {
|
||||||
|
@ -98,10 +102,14 @@
|
||||||
barStyle () {
|
barStyle () {
|
||||||
let style = {
|
let style = {
|
||||||
display: 'none',
|
display: 'none',
|
||||||
width: `${this.barWidth}px`,
|
width: `${this.barWidth}px`
|
||||||
transform: `translate3d(${this.barOffset}px, 0px, 0px)`
|
|
||||||
};
|
};
|
||||||
if (this.type === 'line') style.display = 'block';
|
if (this.type === 'line') style.display = 'block';
|
||||||
|
if (this.animated) {
|
||||||
|
style.transform = `translate3d(${this.barOffset}px, 0px, 0px)`;
|
||||||
|
} else {
|
||||||
|
style.left = `${this.barOffset}px`;
|
||||||
|
}
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
@ -124,6 +132,7 @@
|
||||||
if (!this.activeKey) this.activeKey = pane.key || index;
|
if (!this.activeKey) this.activeKey = pane.key || index;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.updateStatus();
|
||||||
this.updateBar();
|
this.updateBar();
|
||||||
},
|
},
|
||||||
updateBar () {
|
updateBar () {
|
||||||
|
@ -146,6 +155,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
updateStatus () {
|
||||||
|
const tabs = this.getTabs();
|
||||||
|
tabs.forEach(tab => tab.show = (tab.key === this.activeKey) || this.animated);
|
||||||
|
},
|
||||||
tabCls (item) {
|
tabCls (item) {
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-tab`,
|
`${prefixCls}-tab`,
|
||||||
|
@ -159,6 +172,7 @@
|
||||||
const nav = this.navList[index];
|
const nav = this.navList[index];
|
||||||
if (nav.disabled) return;
|
if (nav.disabled) return;
|
||||||
this.activeKey = nav.key;
|
this.activeKey = nav.key;
|
||||||
|
this.updateStatus();
|
||||||
this.$emit('on-click', nav.key);
|
this.$emit('on-click', nav.key);
|
||||||
},
|
},
|
||||||
handleRemove (index) {
|
handleRemove (index) {
|
||||||
|
|
|
@ -194,9 +194,7 @@
|
||||||
|
|
||||||
.@{tabs-prefix-cls}-no-animation{
|
.@{tabs-prefix-cls}-no-animation{
|
||||||
.@{tabs-prefix-cls}-content {
|
.@{tabs-prefix-cls}-content {
|
||||||
&-animated {
|
transform: none!important;
|
||||||
transform: none!important;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .@{tabs-prefix-cls}-tabpane-inactive {
|
> .@{tabs-prefix-cls}-tabpane-inactive {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<i-button @click="toggleClose" :animated="false">closable</i-button>
|
<i-button @click="toggleClose">closable</i-button>
|
||||||
|
|
||||||
<Tabs type="line" :closable="closable" :animated="false">
|
<Tabs type="line" :closable="closable" :animated="false">
|
||||||
<Tab-pane label="Tab 1">Tab1 content</Tab-pane>
|
<Tab-pane label="Tab 1">Tab1 content</Tab-pane>
|
||||||
|
|
Loading…
Add table
Reference in a new issue