first
This commit is contained in:
90
node_modules/vant/lib/tabs/Content.js
generated
vendored
Normal file
90
node_modules/vant/lib/tabs/Content.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.default = void 0;
|
||||
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
|
||||
var _utils = require("../utils");
|
||||
|
||||
var _touch = require("../mixins/touch");
|
||||
|
||||
var _createNamespace = (0, _utils.createNamespace)('tabs'),
|
||||
createComponent = _createNamespace[0],
|
||||
bem = _createNamespace[1];
|
||||
|
||||
var MIN_SWIPE_DISTANCE = 50;
|
||||
|
||||
var _default = createComponent({
|
||||
mixins: [_touch.TouchMixin],
|
||||
props: {
|
||||
count: Number,
|
||||
duration: [Number, String],
|
||||
animated: Boolean,
|
||||
swipeable: Boolean,
|
||||
currentIndex: Number
|
||||
},
|
||||
computed: {
|
||||
style: function style() {
|
||||
if (this.animated) {
|
||||
return {
|
||||
transform: "translate3d(" + -1 * this.currentIndex * 100 + "%, 0, 0)",
|
||||
transitionDuration: this.duration + "s"
|
||||
};
|
||||
}
|
||||
},
|
||||
listeners: function listeners() {
|
||||
if (this.swipeable) {
|
||||
return {
|
||||
touchstart: this.touchStart,
|
||||
touchmove: this.touchMove,
|
||||
touchend: this.onTouchEnd,
|
||||
touchcancel: this.onTouchEnd
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// watch swipe touch end
|
||||
onTouchEnd: function onTouchEnd() {
|
||||
var direction = this.direction,
|
||||
deltaX = this.deltaX,
|
||||
currentIndex = this.currentIndex;
|
||||
/* istanbul ignore else */
|
||||
|
||||
if (direction === 'horizontal' && this.offsetX >= MIN_SWIPE_DISTANCE) {
|
||||
/* istanbul ignore else */
|
||||
if (deltaX > 0 && currentIndex !== 0) {
|
||||
this.$emit('change', currentIndex - 1);
|
||||
} else if (deltaX < 0 && currentIndex !== this.count - 1) {
|
||||
this.$emit('change', currentIndex + 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
genChildren: function genChildren() {
|
||||
var h = this.$createElement;
|
||||
|
||||
if (this.animated) {
|
||||
return h("div", {
|
||||
"class": bem('track'),
|
||||
"style": this.style
|
||||
}, [this.slots()]);
|
||||
}
|
||||
|
||||
return this.slots();
|
||||
}
|
||||
},
|
||||
render: function render() {
|
||||
var h = arguments[0];
|
||||
return h("div", {
|
||||
"class": bem('content', {
|
||||
animated: this.animated
|
||||
}),
|
||||
"on": (0, _extends2.default)({}, this.listeners)
|
||||
}, [this.genChildren()]);
|
||||
}
|
||||
});
|
||||
|
||||
exports.default = _default;
|
102
node_modules/vant/lib/tabs/Title.js
generated
vendored
Normal file
102
node_modules/vant/lib/tabs/Title.js
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.default = void 0;
|
||||
|
||||
var _utils = require("../utils");
|
||||
|
||||
var _info = _interopRequireDefault(require("../info"));
|
||||
|
||||
var _createNamespace = (0, _utils.createNamespace)('tab'),
|
||||
createComponent = _createNamespace[0],
|
||||
bem = _createNamespace[1];
|
||||
|
||||
var _default = createComponent({
|
||||
props: {
|
||||
dot: Boolean,
|
||||
type: String,
|
||||
info: [Number, String],
|
||||
color: String,
|
||||
title: String,
|
||||
isActive: Boolean,
|
||||
disabled: Boolean,
|
||||
scrollable: Boolean,
|
||||
activeColor: String,
|
||||
inactiveColor: String
|
||||
},
|
||||
computed: {
|
||||
style: function style() {
|
||||
var style = {};
|
||||
var color = this.color,
|
||||
isActive = this.isActive;
|
||||
var isCard = this.type === 'card'; // card theme color
|
||||
|
||||
if (color && isCard) {
|
||||
style.borderColor = color;
|
||||
|
||||
if (!this.disabled) {
|
||||
if (isActive) {
|
||||
style.backgroundColor = color;
|
||||
} else {
|
||||
style.color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var titleColor = isActive ? this.activeColor : this.inactiveColor;
|
||||
|
||||
if (titleColor) {
|
||||
style.color = titleColor;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick: function onClick() {
|
||||
this.$emit('click');
|
||||
},
|
||||
genText: function genText() {
|
||||
var h = this.$createElement;
|
||||
var Text = h("span", {
|
||||
"class": bem('text', {
|
||||
ellipsis: !this.scrollable
|
||||
})
|
||||
}, [this.slots() || this.title]);
|
||||
|
||||
if (this.dot || (0, _utils.isDef)(this.info) && this.info !== '') {
|
||||
return h("span", {
|
||||
"class": bem('text-wrapper')
|
||||
}, [Text, h(_info.default, {
|
||||
"attrs": {
|
||||
"dot": this.dot,
|
||||
"info": this.info
|
||||
}
|
||||
})]);
|
||||
}
|
||||
|
||||
return Text;
|
||||
}
|
||||
},
|
||||
render: function render() {
|
||||
var h = arguments[0];
|
||||
return h("div", {
|
||||
"attrs": {
|
||||
"role": "tab",
|
||||
"aria-selected": this.isActive
|
||||
},
|
||||
"class": [bem({
|
||||
active: this.isActive,
|
||||
disabled: this.disabled
|
||||
})],
|
||||
"style": this.style,
|
||||
"on": {
|
||||
"click": this.onClick
|
||||
}
|
||||
}, [this.genText()]);
|
||||
}
|
||||
});
|
||||
|
||||
exports.default = _default;
|
1
node_modules/vant/lib/tabs/index.css
generated
vendored
Normal file
1
node_modules/vant/lib/tabs/index.css
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
.van-tab{position:relative;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-flex:1;-webkit-flex:1;flex:1;-webkit-box-align:center;-webkit-align-items:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0 4px;color:#646566;font-size:14px;line-height:20px;cursor:pointer}.van-tab--active{color:#323233;font-weight:500}.van-tab--disabled{color:#c8c9cc;cursor:not-allowed}.van-tab__text--ellipsis{display:-webkit-box;overflow:hidden;-webkit-line-clamp:1;-webkit-box-orient:vertical}.van-tab__text-wrapper{position:relative}.van-tabs{position:relative}.van-tabs__wrap{overflow:hidden}.van-tabs__wrap--page-top{position:fixed}.van-tabs__wrap--content-bottom{top:auto;bottom:0}.van-tabs__wrap--scrollable .van-tab{-webkit-box-flex:1;-webkit-flex:1 0 auto;flex:1 0 auto;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}.van-tabs__wrap--scrollable .van-tabs__nav::-webkit-scrollbar{display:none}.van-tabs__nav{position:relative;display:-webkit-box;display:-webkit-flex;display:flex;background-color:#fff;-webkit-user-select:none;user-select:none}.van-tabs__nav--line{box-sizing:content-box;height:100%;padding-bottom:15px}.van-tabs__nav--line.van-tabs__nav--complete{padding-right:8px;padding-left:8px}.van-tabs__nav--card{box-sizing:border-box;height:30px;margin:0 16px;border:1px solid #ee0a24;border-radius:2px}.van-tabs__nav--card .van-tab{color:#ee0a24;border-right:1px solid #ee0a24}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;background-color:#ee0a24}.van-tabs__nav--card .van-tab--disabled{color:#c8c9cc}.van-tabs__line{position:absolute;bottom:15px;left:0;z-index:1;width:40px;height:3px;background-color:#ee0a24;border-radius:3px}.van-tabs__track{position:relative;display:-webkit-box;display:-webkit-flex;display:flex;width:100%;height:100%;will-change:left}.van-tabs__content--animated{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:44px}.van-tabs--card>.van-tabs__wrap{height:30px}
|
454
node_modules/vant/lib/tabs/index.js
generated
vendored
Normal file
454
node_modules/vant/lib/tabs/index.js
generated
vendored
Normal file
@ -0,0 +1,454 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.default = void 0;
|
||||
|
||||
var _utils = require("../utils");
|
||||
|
||||
var _utils2 = require("./utils");
|
||||
|
||||
var _router = require("../utils/router");
|
||||
|
||||
var _style = require("../utils/dom/style");
|
||||
|
||||
var _event = require("../utils/dom/event");
|
||||
|
||||
var _unit = require("../utils/format/unit");
|
||||
|
||||
var _constant = require("../utils/constant");
|
||||
|
||||
var _interceptor = require("../utils/interceptor");
|
||||
|
||||
var _scroll = require("../utils/dom/scroll");
|
||||
|
||||
var _relation = require("../mixins/relation");
|
||||
|
||||
var _bindEvent = require("../mixins/bind-event");
|
||||
|
||||
var _Title = _interopRequireDefault(require("./Title"));
|
||||
|
||||
var _sticky = _interopRequireDefault(require("../sticky"));
|
||||
|
||||
var _Content = _interopRequireDefault(require("./Content"));
|
||||
|
||||
// Utils
|
||||
// Mixins
|
||||
// Components
|
||||
var _createNamespace = (0, _utils.createNamespace)('tabs'),
|
||||
createComponent = _createNamespace[0],
|
||||
bem = _createNamespace[1];
|
||||
|
||||
var _default2 = createComponent({
|
||||
mixins: [(0, _relation.ParentMixin)('vanTabs'), (0, _bindEvent.BindEventMixin)(function (bind) {
|
||||
if (!this.scroller) {
|
||||
this.scroller = (0, _scroll.getScroller)(this.$el);
|
||||
}
|
||||
|
||||
bind(window, 'resize', this.resize, true);
|
||||
|
||||
if (this.scrollspy) {
|
||||
bind(this.scroller, 'scroll', this.onScroll, true);
|
||||
}
|
||||
})],
|
||||
inject: {
|
||||
vanPopup: {
|
||||
default: null
|
||||
}
|
||||
},
|
||||
model: {
|
||||
prop: 'active'
|
||||
},
|
||||
props: {
|
||||
color: String,
|
||||
border: Boolean,
|
||||
sticky: Boolean,
|
||||
animated: Boolean,
|
||||
swipeable: Boolean,
|
||||
scrollspy: Boolean,
|
||||
background: String,
|
||||
lineWidth: [Number, String],
|
||||
lineHeight: [Number, String],
|
||||
beforeChange: Function,
|
||||
titleActiveColor: String,
|
||||
titleInactiveColor: String,
|
||||
type: {
|
||||
type: String,
|
||||
default: 'line'
|
||||
},
|
||||
active: {
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
},
|
||||
ellipsis: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
duration: {
|
||||
type: [Number, String],
|
||||
default: 0.3
|
||||
},
|
||||
offsetTop: {
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
},
|
||||
lazyRender: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
swipeThreshold: {
|
||||
type: [Number, String],
|
||||
default: 5
|
||||
}
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
position: '',
|
||||
currentIndex: null,
|
||||
lineStyle: {
|
||||
backgroundColor: this.color
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// whether the nav is scrollable
|
||||
scrollable: function scrollable() {
|
||||
return this.children.length > this.swipeThreshold || !this.ellipsis;
|
||||
},
|
||||
navStyle: function navStyle() {
|
||||
return {
|
||||
borderColor: this.color,
|
||||
background: this.background
|
||||
};
|
||||
},
|
||||
currentName: function currentName() {
|
||||
var activeTab = this.children[this.currentIndex];
|
||||
|
||||
if (activeTab) {
|
||||
return activeTab.computedName;
|
||||
}
|
||||
},
|
||||
offsetTopPx: function offsetTopPx() {
|
||||
return (0, _unit.unitToPx)(this.offsetTop);
|
||||
},
|
||||
scrollOffset: function scrollOffset() {
|
||||
if (this.sticky) {
|
||||
return this.offsetTopPx + this.tabHeight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
color: 'setLine',
|
||||
active: function active(name) {
|
||||
if (name !== this.currentName) {
|
||||
this.setCurrentIndexByName(name);
|
||||
}
|
||||
},
|
||||
children: function children() {
|
||||
var _this = this;
|
||||
|
||||
this.setCurrentIndexByName(this.active);
|
||||
this.setLine();
|
||||
this.$nextTick(function () {
|
||||
_this.scrollIntoView(true);
|
||||
});
|
||||
},
|
||||
currentIndex: function currentIndex() {
|
||||
this.scrollIntoView();
|
||||
this.setLine(); // scroll to correct position
|
||||
|
||||
if (this.stickyFixed && !this.scrollspy) {
|
||||
(0, _scroll.setRootScrollTop)(Math.ceil((0, _scroll.getElementTop)(this.$el) - this.offsetTopPx));
|
||||
}
|
||||
},
|
||||
scrollspy: function scrollspy(val) {
|
||||
if (val) {
|
||||
(0, _event.on)(this.scroller, 'scroll', this.onScroll, true);
|
||||
} else {
|
||||
(0, _event.off)(this.scroller, 'scroll', this.onScroll);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted: function mounted() {
|
||||
var _this2 = this;
|
||||
|
||||
this.init(); // https://github.com/vant-ui/vant/issues/7959
|
||||
|
||||
if (this.vanPopup) {
|
||||
this.vanPopup.onReopen(function () {
|
||||
_this2.setLine();
|
||||
});
|
||||
}
|
||||
},
|
||||
activated: function activated() {
|
||||
this.init();
|
||||
this.setLine();
|
||||
},
|
||||
methods: {
|
||||
// @exposed-api
|
||||
resize: function resize() {
|
||||
this.setLine();
|
||||
},
|
||||
init: function init() {
|
||||
var _this3 = this;
|
||||
|
||||
this.$nextTick(function () {
|
||||
_this3.inited = true;
|
||||
_this3.tabHeight = (0, _scroll.getVisibleHeight)(_this3.$refs.wrap);
|
||||
|
||||
_this3.scrollIntoView(true);
|
||||
});
|
||||
},
|
||||
// update nav bar style
|
||||
setLine: function setLine() {
|
||||
var _this4 = this;
|
||||
|
||||
var shouldAnimate = this.inited;
|
||||
this.$nextTick(function () {
|
||||
var titles = _this4.$refs.titles;
|
||||
|
||||
if (!titles || !titles[_this4.currentIndex] || _this4.type !== 'line' || (0, _style.isHidden)(_this4.$el)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var title = titles[_this4.currentIndex].$el;
|
||||
var lineWidth = _this4.lineWidth,
|
||||
lineHeight = _this4.lineHeight;
|
||||
var left = title.offsetLeft + title.offsetWidth / 2;
|
||||
var lineStyle = {
|
||||
width: (0, _utils.addUnit)(lineWidth),
|
||||
backgroundColor: _this4.color,
|
||||
transform: "translateX(" + left + "px) translateX(-50%)"
|
||||
};
|
||||
|
||||
if (shouldAnimate) {
|
||||
lineStyle.transitionDuration = _this4.duration + "s";
|
||||
}
|
||||
|
||||
if ((0, _utils.isDef)(lineHeight)) {
|
||||
var height = (0, _utils.addUnit)(lineHeight);
|
||||
lineStyle.height = height;
|
||||
lineStyle.borderRadius = height;
|
||||
}
|
||||
|
||||
_this4.lineStyle = lineStyle;
|
||||
});
|
||||
},
|
||||
// correct the index of active tab
|
||||
setCurrentIndexByName: function setCurrentIndexByName(name) {
|
||||
var matched = this.children.filter(function (tab) {
|
||||
return tab.computedName === name;
|
||||
});
|
||||
var defaultIndex = (this.children[0] || {}).index || 0;
|
||||
this.setCurrentIndex(matched.length ? matched[0].index : defaultIndex);
|
||||
},
|
||||
setCurrentIndex: function setCurrentIndex(currentIndex) {
|
||||
var newIndex = this.findAvailableTab(currentIndex);
|
||||
|
||||
if (!(0, _utils.isDef)(newIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var newTab = this.children[newIndex];
|
||||
var newName = newTab.computedName;
|
||||
var shouldEmitChange = this.currentIndex !== null;
|
||||
this.currentIndex = newIndex;
|
||||
|
||||
if (newName !== this.active) {
|
||||
this.$emit('input', newName);
|
||||
|
||||
if (shouldEmitChange) {
|
||||
this.$emit('change', newName, newTab.title);
|
||||
}
|
||||
}
|
||||
},
|
||||
findAvailableTab: function findAvailableTab(index) {
|
||||
var diff = index < this.currentIndex ? -1 : 1;
|
||||
|
||||
while (index >= 0 && index < this.children.length) {
|
||||
if (!this.children[index].disabled) {
|
||||
return index;
|
||||
}
|
||||
|
||||
index += diff;
|
||||
}
|
||||
},
|
||||
// emit event when clicked
|
||||
onClick: function onClick(item, index) {
|
||||
var _this5 = this;
|
||||
|
||||
var _this$children$index = this.children[index],
|
||||
title = _this$children$index.title,
|
||||
disabled = _this$children$index.disabled,
|
||||
computedName = _this$children$index.computedName;
|
||||
|
||||
if (disabled) {
|
||||
this.$emit('disabled', computedName, title);
|
||||
} else {
|
||||
(0, _interceptor.callInterceptor)({
|
||||
interceptor: this.beforeChange,
|
||||
args: [computedName],
|
||||
done: function done() {
|
||||
_this5.setCurrentIndex(index);
|
||||
|
||||
_this5.scrollToCurrentContent();
|
||||
}
|
||||
});
|
||||
this.$emit('click', computedName, title);
|
||||
(0, _router.route)(item.$router, item);
|
||||
}
|
||||
},
|
||||
// scroll active tab into view
|
||||
scrollIntoView: function scrollIntoView(immediate) {
|
||||
var titles = this.$refs.titles;
|
||||
|
||||
if (!this.scrollable || !titles || !titles[this.currentIndex]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var nav = this.$refs.nav;
|
||||
var title = titles[this.currentIndex].$el;
|
||||
var to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
|
||||
(0, _utils2.scrollLeftTo)(nav, to, immediate ? 0 : +this.duration);
|
||||
},
|
||||
onSticktScroll: function onSticktScroll(params) {
|
||||
this.stickyFixed = params.isFixed;
|
||||
this.$emit('scroll', params);
|
||||
},
|
||||
// @exposed-api
|
||||
scrollTo: function scrollTo(name) {
|
||||
var _this6 = this;
|
||||
|
||||
this.$nextTick(function () {
|
||||
_this6.setCurrentIndexByName(name);
|
||||
|
||||
_this6.scrollToCurrentContent(true);
|
||||
});
|
||||
},
|
||||
scrollToCurrentContent: function scrollToCurrentContent(immediate) {
|
||||
var _this7 = this;
|
||||
|
||||
if (immediate === void 0) {
|
||||
immediate = false;
|
||||
}
|
||||
|
||||
if (this.scrollspy) {
|
||||
var target = this.children[this.currentIndex];
|
||||
var el = target == null ? void 0 : target.$el;
|
||||
|
||||
if (el) {
|
||||
var to = (0, _scroll.getElementTop)(el, this.scroller) - this.scrollOffset;
|
||||
this.lockScroll = true;
|
||||
(0, _utils2.scrollTopTo)(this.scroller, to, immediate ? 0 : +this.duration, function () {
|
||||
_this7.lockScroll = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
onScroll: function onScroll() {
|
||||
if (this.scrollspy && !this.lockScroll) {
|
||||
var index = this.getCurrentIndexOnScroll();
|
||||
this.setCurrentIndex(index);
|
||||
}
|
||||
},
|
||||
getCurrentIndexOnScroll: function getCurrentIndexOnScroll() {
|
||||
var children = this.children;
|
||||
|
||||
for (var index = 0; index < children.length; index++) {
|
||||
var top = (0, _scroll.getVisibleTop)(children[index].$el);
|
||||
|
||||
if (top > this.scrollOffset) {
|
||||
return index === 0 ? 0 : index - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return children.length - 1;
|
||||
}
|
||||
},
|
||||
render: function render() {
|
||||
var _this8 = this,
|
||||
_ref;
|
||||
|
||||
var h = arguments[0];
|
||||
var type = this.type,
|
||||
animated = this.animated,
|
||||
scrollable = this.scrollable;
|
||||
var Nav = this.children.map(function (item, index) {
|
||||
var _item$badge;
|
||||
|
||||
return h(_Title.default, {
|
||||
"ref": "titles",
|
||||
"refInFor": true,
|
||||
"attrs": {
|
||||
"type": type,
|
||||
"dot": item.dot,
|
||||
"info": (_item$badge = item.badge) != null ? _item$badge : item.info,
|
||||
"title": item.title,
|
||||
"color": _this8.color,
|
||||
"isActive": index === _this8.currentIndex,
|
||||
"disabled": item.disabled,
|
||||
"scrollable": scrollable,
|
||||
"activeColor": _this8.titleActiveColor,
|
||||
"inactiveColor": _this8.titleInactiveColor
|
||||
},
|
||||
"style": item.titleStyle,
|
||||
"class": item.titleClass,
|
||||
"scopedSlots": {
|
||||
default: function _default() {
|
||||
return item.slots('title');
|
||||
}
|
||||
},
|
||||
"on": {
|
||||
"click": function click() {
|
||||
_this8.onClick(item, index);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
var Wrap = h("div", {
|
||||
"ref": "wrap",
|
||||
"class": [bem('wrap', {
|
||||
scrollable: scrollable
|
||||
}), (_ref = {}, _ref[_constant.BORDER_TOP_BOTTOM] = type === 'line' && this.border, _ref)]
|
||||
}, [h("div", {
|
||||
"ref": "nav",
|
||||
"attrs": {
|
||||
"role": "tablist"
|
||||
},
|
||||
"class": bem('nav', [type, {
|
||||
complete: this.scrollable
|
||||
}]),
|
||||
"style": this.navStyle
|
||||
}, [this.slots('nav-left'), Nav, type === 'line' && h("div", {
|
||||
"class": bem('line'),
|
||||
"style": this.lineStyle
|
||||
}), this.slots('nav-right')])]);
|
||||
return h("div", {
|
||||
"class": bem([type])
|
||||
}, [this.sticky ? h(_sticky.default, {
|
||||
"attrs": {
|
||||
"container": this.$el,
|
||||
"offsetTop": this.offsetTop
|
||||
},
|
||||
"on": {
|
||||
"scroll": this.onSticktScroll
|
||||
}
|
||||
}, [Wrap]) : Wrap, h(_Content.default, {
|
||||
"attrs": {
|
||||
"count": this.children.length,
|
||||
"animated": animated,
|
||||
"duration": this.duration,
|
||||
"swipeable": this.swipeable,
|
||||
"currentIndex": this.currentIndex
|
||||
},
|
||||
"on": {
|
||||
"change": this.setCurrentIndex
|
||||
}
|
||||
}, [this.slots()])]);
|
||||
}
|
||||
});
|
||||
|
||||
exports.default = _default2;
|
153
node_modules/vant/lib/tabs/index.less
generated
vendored
Normal file
153
node_modules/vant/lib/tabs/index.less
generated
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van-tab {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
padding: 0 @padding-base;
|
||||
color: @tab-text-color;
|
||||
font-size: @tab-font-size;
|
||||
line-height: @tab-line-height;
|
||||
cursor: pointer;
|
||||
|
||||
&--active {
|
||||
color: @tab-active-text-color;
|
||||
font-weight: @font-weight-bold;
|
||||
}
|
||||
|
||||
&--disabled {
|
||||
color: @tab-disabled-text-color;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&__text {
|
||||
&--ellipsis {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
-webkit-line-clamp: 1;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
}
|
||||
|
||||
&__text-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.van-tabs {
|
||||
position: relative;
|
||||
|
||||
&__wrap {
|
||||
overflow: hidden;
|
||||
|
||||
&--page-top {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
&--content-bottom {
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
&--scrollable {
|
||||
.van-tab {
|
||||
flex: 1 0 auto;
|
||||
padding: 0 @padding-sm;
|
||||
}
|
||||
|
||||
.van-tabs__nav {
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__nav {
|
||||
position: relative;
|
||||
display: flex;
|
||||
background-color: @tabs-nav-background-color;
|
||||
user-select: none;
|
||||
|
||||
&--line {
|
||||
box-sizing: content-box;
|
||||
height: 100%;
|
||||
padding-bottom: 15px; /* 15px padding to hide scrollbar in mobile safari */
|
||||
}
|
||||
|
||||
&--line&--complete {
|
||||
padding-right: @padding-xs;
|
||||
padding-left: @padding-xs;
|
||||
}
|
||||
|
||||
&--card {
|
||||
box-sizing: border-box;
|
||||
height: @tabs-card-height;
|
||||
margin: 0 @padding-md;
|
||||
border: @border-width-base solid @tabs-default-color;
|
||||
border-radius: @border-radius-sm;
|
||||
|
||||
.van-tab {
|
||||
color: @tabs-default-color;
|
||||
border-right: @border-width-base solid @tabs-default-color;
|
||||
|
||||
&:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
&.van-tab--active {
|
||||
color: @white;
|
||||
background-color: @tabs-default-color;
|
||||
}
|
||||
|
||||
&--disabled {
|
||||
color: @tab-disabled-text-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__line {
|
||||
position: absolute;
|
||||
bottom: 15px;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
width: @tabs-bottom-bar-width;
|
||||
height: @tabs-bottom-bar-height;
|
||||
background-color: @tabs-bottom-bar-color;
|
||||
border-radius: @tabs-bottom-bar-height;
|
||||
}
|
||||
|
||||
&__track {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
will-change: left;
|
||||
}
|
||||
|
||||
&__content {
|
||||
&--animated {
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
&--line {
|
||||
.van-tabs__wrap {
|
||||
height: @tabs-line-height;
|
||||
}
|
||||
}
|
||||
|
||||
&--card {
|
||||
> .van-tabs__wrap {
|
||||
height: @tabs-card-height;
|
||||
}
|
||||
}
|
||||
}
|
4
node_modules/vant/lib/tabs/style/index.js
generated
vendored
Normal file
4
node_modules/vant/lib/tabs/style/index.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
require('../../style/base.css');
|
||||
require('../../info/index.css');
|
||||
require('../../sticky/index.css');
|
||||
require('../index.css');
|
4
node_modules/vant/lib/tabs/style/less.js
generated
vendored
Normal file
4
node_modules/vant/lib/tabs/style/less.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
require('../../style/base.less');
|
||||
require('../../info/index.less');
|
||||
require('../../sticky/index.less');
|
||||
require('../index.less');
|
50
node_modules/vant/lib/tabs/utils.js
generated
vendored
Normal file
50
node_modules/vant/lib/tabs/utils.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.scrollLeftTo = scrollLeftTo;
|
||||
exports.scrollTopTo = scrollTopTo;
|
||||
|
||||
var _raf = require("../utils/dom/raf");
|
||||
|
||||
var _scroll = require("../utils/dom/scroll");
|
||||
|
||||
function scrollLeftTo(scroller, to, duration) {
|
||||
var count = 0;
|
||||
var from = scroller.scrollLeft;
|
||||
var frames = duration === 0 ? 1 : Math.round(duration * 1000 / 16);
|
||||
|
||||
function animate() {
|
||||
scroller.scrollLeft += (to - from) / frames;
|
||||
|
||||
if (++count < frames) {
|
||||
(0, _raf.raf)(animate);
|
||||
}
|
||||
}
|
||||
|
||||
animate();
|
||||
}
|
||||
|
||||
function scrollTopTo(scroller, to, duration, callback) {
|
||||
var current = (0, _scroll.getScrollTop)(scroller);
|
||||
var isDown = current < to;
|
||||
var frames = duration === 0 ? 1 : Math.round(duration * 1000 / 16);
|
||||
var step = (to - current) / frames;
|
||||
|
||||
function animate() {
|
||||
current += step;
|
||||
|
||||
if (isDown && current > to || !isDown && current < to) {
|
||||
current = to;
|
||||
}
|
||||
|
||||
(0, _scroll.setScrollTop)(scroller, current);
|
||||
|
||||
if (isDown && current < to || !isDown && current > to) {
|
||||
(0, _raf.raf)(animate);
|
||||
} else if (callback) {
|
||||
(0, _raf.raf)(callback);
|
||||
}
|
||||
}
|
||||
|
||||
animate();
|
||||
}
|
Reference in New Issue
Block a user