[new feature] Tab: add line height prop (#2357)

This commit is contained in:
neverland
2018-12-22 08:56:29 +08:00
committed by GitHub
parent d77a240a49
commit dec920e36e
4 changed files with 19 additions and 4 deletions
+2 -2
View File
@@ -112,9 +112,9 @@
z-index: 1;
left: 0;
bottom: 15px;
height: 2px;
height: 3px;
position: absolute;
border-radius: 2px;
border-radius: 3px;
background-color: @red;
}
+15 -2
View File
@@ -85,6 +85,10 @@ export default create({
type: Number,
default: null
},
lineHeight: {
type: Number,
default: null
},
active: {
type: [Number, String],
default: 0
@@ -298,15 +302,24 @@ export default create({
}
const tab = tabs[this.curActive];
const width = this.isDef(this.lineWidth) ? this.lineWidth : (tab.offsetWidth / 2);
const { lineWidth, lineHeight } = this;
const width = this.isDef(lineWidth) ? lineWidth : (tab.offsetWidth / 2);
const left = tab.offsetLeft + (tab.offsetWidth - width) / 2;
this.lineStyle = {
const lineStyle = {
width: `${width}px`,
backgroundColor: this.color,
transform: `translateX(${left}px)`,
transitionDuration: `${this.duration}s`
};
if (this.isDef(lineHeight)) {
const height = `${lineHeight}px`;
lineStyle.height = height;
lineStyle.borderRadius = height;
}
this.lineStyle = lineStyle;
});
},