index.wxs 1.5 KB

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