index.wxs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 trackStyle(data) {
  46. if (!data.animated) {
  47. return '';
  48. }
  49. return [
  50. 'transform: translate3d(' + -100 * data.currentIndex + '%, 0, 0)',
  51. '-webkit-transition-duration: ' + data.duration + 's',
  52. 'transition-duration: ' + data.duration + 's'
  53. ].join(';');
  54. }
  55. module.exports.tabClass = tabClass;
  56. module.exports.tabStyle = tabStyle;
  57. module.exports.trackStyle = trackStyle;