mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[new feature] Tab: add line-height prop (#1205)
This commit is contained in:
parent
7fbe5cd789
commit
efc74f7782
@ -7,18 +7,18 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
title: String,
|
|
||||||
disabled: Boolean,
|
|
||||||
dot: Boolean,
|
dot: Boolean,
|
||||||
info: null,
|
info: null,
|
||||||
|
title: String,
|
||||||
|
disabled: Boolean,
|
||||||
titleStyle: String
|
titleStyle: String
|
||||||
},
|
},
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
|
width: null,
|
||||||
inited: false,
|
inited: false,
|
||||||
active: false,
|
active: false,
|
||||||
animated: false,
|
animated: false
|
||||||
width: null
|
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -69,9 +69,9 @@
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
height: 2px;
|
height: 3px;
|
||||||
background-color: @red;
|
background-color: @red;
|
||||||
border-radius: 2px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--line {
|
&--line {
|
||||||
|
@ -2,10 +2,10 @@ import { VantComponent } from '../common/component';
|
|||||||
import { touch } from '../mixins/touch';
|
import { touch } from '../mixins/touch';
|
||||||
|
|
||||||
type TabItemData = {
|
type TabItemData = {
|
||||||
|
width?: number;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
inited?: boolean;
|
inited?: boolean;
|
||||||
animated?: boolean;
|
animated?: boolean;
|
||||||
width?: Number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
@ -29,10 +29,17 @@ VantComponent({
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
color: String,
|
color: String,
|
||||||
|
sticky: Boolean,
|
||||||
|
animated: Boolean,
|
||||||
|
swipeable: Boolean,
|
||||||
lineWidth: {
|
lineWidth: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: -1
|
value: -1
|
||||||
},
|
},
|
||||||
|
lineHeight: {
|
||||||
|
type: Number,
|
||||||
|
value: -1
|
||||||
|
},
|
||||||
active: {
|
active: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0
|
value: 0
|
||||||
@ -57,13 +64,10 @@ VantComponent({
|
|||||||
type: Number,
|
type: Number,
|
||||||
value: 4
|
value: 4
|
||||||
},
|
},
|
||||||
animated: Boolean,
|
|
||||||
sticky: Boolean,
|
|
||||||
offsetTop: {
|
offsetTop: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0
|
value: 0
|
||||||
},
|
}
|
||||||
swipeable: Boolean
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
@ -84,6 +88,7 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
color: 'setLine',
|
color: 'setLine',
|
||||||
lineWidth: 'setLine',
|
lineWidth: 'setLine',
|
||||||
|
lineHeight: 'setLine',
|
||||||
active: 'setActiveTab',
|
active: 'setActiveTab',
|
||||||
animated: 'setTrack',
|
animated: 'setTrack',
|
||||||
offsetTop: 'setWrapStyle'
|
offsetTop: 'setWrapStyle'
|
||||||
@ -149,12 +154,14 @@ VantComponent({
|
|||||||
color,
|
color,
|
||||||
active,
|
active,
|
||||||
duration,
|
duration,
|
||||||
lineWidth
|
lineWidth,
|
||||||
|
lineHeight
|
||||||
} = this.data;
|
} = this.data;
|
||||||
|
|
||||||
this.getRect('.van-tab', true).then(rects => {
|
this.getRect('.van-tab', true).then(rects => {
|
||||||
const rect = rects[active];
|
const rect = rects[active];
|
||||||
const width = (lineWidth !== -1) ? lineWidth : rect.width / 2;
|
const width = (lineWidth !== -1) ? lineWidth : rect.width / 2;
|
||||||
|
const height = lineHeight !== -1 ? `height: ${lineHeight}px;` : '';
|
||||||
|
|
||||||
let left = rects
|
let left = rects
|
||||||
.slice(0, active)
|
.slice(0, active)
|
||||||
@ -164,6 +171,7 @@ VantComponent({
|
|||||||
|
|
||||||
this.set({
|
this.set({
|
||||||
lineStyle: `
|
lineStyle: `
|
||||||
|
${height}
|
||||||
width: ${width}px;
|
width: ${width}px;
|
||||||
background-color: ${color};
|
background-color: ${color};
|
||||||
-webkit-transform: translateX(${left}px);
|
-webkit-transform: translateX(${left}px);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user