index.wxs
1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function tabClass(active, ellipsis) {
var classes = ['tab-class'];
if (active) {
classes.push('tab-active-class')
};
if (ellipsis) {
classes.push('van-ellipsis')
};
return (classes.join(' '))
};
function tabStyle(active, ellipsis, color, type, disabled, activeColor, inactiveColor, swipeThreshold, scrollable) {
var styles = [];
var isCard = type === 'card';
if (color && isCard) {
styles.push('border-color:' + color);
if (!disabled) {
if (active) {
styles.push('background-color:' + color)
} else {
styles.push('color:' + color)
}
}
};
var titleColor = active ? activeColor : inactiveColor;
if (titleColor) {
styles.push('color:' + titleColor)
};
if (scrollable && ellipsis) {
styles.push('flex-basis:' + 88 / swipeThreshold + '%')
};
return (styles.join(';'))
};
function tabCardTypeBorderStyle(color, type) {
var isCard = type === 'card';
var styles = [];
if (isCard && color) {
styles.push('border-color:' + color)
};
return (styles.join(';'))
};
function trackStyle(data) {
if (!data.animated) {
return ('')
};
return (['transform: translate3d(' + -100 * data.currentIndex + '%, 0, 0)', '-webkit-transition-duration: ' + data.duration + 's', 'transition-duration: ' + data.duration + 's'].join(';'))
};
module.exports.tabClass = tabClass;
module.exports.tabStyle = tabStyle;
module.exports.trackStyle = trackStyle;
module.exports.tabCardTypeBorderStyle = tabCardTypeBorderStyle;