You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
5.3 KiB
1 line
5.3 KiB
10 months ago
|
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames")),_styleToCssString=_interopRequireDefault(require("../helpers/styleToCssString")),_bound=_interopRequireDefault(require("../helpers/bound")),_props=require("./props");function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(t,e){var r=[],i=!0,n=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(i=(o=s.next()).done)&&(r.push(o.value),!e||r.length!==e);i=!0);}catch(t){n=!0,a=t}finally{try{i||null==s.return||s.return()}finally{if(n)throw a}}return r}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _defineProperty(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var getDefaultActiveKey=function(t){var e=t.filter(function(t){return!t.data.disabled})[0];return e?e.data.key:null},activeKeyIsValid=function(t,e){return t.map(function(t){return t.data.key}).includes(e)},getActiveKey=function(t,e){var r=getDefaultActiveKey(t);return e&&activeKeyIsValid(t,e)?e:r};(0,_baseComponent.default)({relations:{"../tab/index":{type:"child",observer:function(){this.callDebounceFn(this.updated)}}},properties:_props.props,data:{activeKey:"",keys:[],scrollLeft:0,scrollTop:0,showPrevMask:!1,showNextMask:!1,scrollViewStyle:""},observers:{current:function(t){this.data.controlled&&this.updated(t)},justify:function(t){this.setStyles(t)}},computed:{classes:["prefixCls, direction, scroll",function(t,e,r){var i;return{wrap:(0,_classNames2.default)(t,(_defineProperty(i={},"".concat(t,"--").concat(e),e),_defineProperty(i,"".concat(t,"--scroll"),r),i)),scrollView:"".concat(t,"__scroll-view"),prev:(0,_classNames2.default)(["".concat(t,"__mask"),"".concat(t,"__mask--prev")]),next:(0,_classNames2.default)(["".concat(t,"__mask"),"".concat(t,"__mask--next")])}}]},methods:{onScrollFix:function(){var n=this,t=this.data.direction;if("horizontal"===t){if(!this.updateMask){var e=this.useThrottleFn(function(){n.tabsContainerRef().then(function(t){var e=t.containerScrollLeft,r=0<e,i=Math.round(e+t.containerWidth)<Math.round(t.containerScrollWidth);n.setData({showPrevMask:r,showNextMask:i})})},100,{trailing:!0,leading:!0}).run;this.updateMask=e}this.updateMask.call(this)}if("vertical"===t){if(!this.updateMask){var r=this.useThrottleFn(function(){n.tabsContainerRef().then(function(t){var e=t.containerScrollTop,r=0<e,i=Math.round(e+t.containerHeight)<Math.round(t.containerScrollHeight);n.setData({showPrevMask:r,showNextMask:i})})},100,{trailing:!0,leading:!0}).run;this.updateMask=r}this.updateMask.call(this)}},tabsContainerRef:function(){var r=this;return new Promise(function(h){var t=r.data.prefixCls,e=wx.createSelectorQuery().in(r);e.select(".".concat(t,"__scroll-view")).boundingClientRect(),e.select(".".concat(t,"__scroll-view")).fields({size:!0,scrollOffset:!0,properties:["scrollX","scrollY"]}),e.exec(function(t){var e=_slicedToArray(t,2),r=e[0],i=e[1],n=i.width,a=i.height,o=i.scrollWidth,s=i.scrollHeight,l=i.scrollLeft,c=i.scrollTop,u=r.left,d=r.top;h({containerWidth:n,containerHeight:a,containerScrollWidth:o,containerScrollHeight:s,containerScrollLeft:l,containerScrollTop:c,containerOffsetX:u,containerOffsetY:d})})})},setNextScroll:function(t){var n=this,e=this.data,o=e.direction;if(e.scroll){var r=Promise.all([this.tabsContainerRef(),t.activeTabRef()]);return r=(r=r.then(function(t){var e=_slicedToArray(t,2),r=e[0],i=e[1];if("horizontal"===o){var n=r.containerScrollWidth-r.containerWidth;return n<=0?[]:[Math.round((0,_bound.default)(r.containerScrollLeft+(i.activeTabLeft-r.containerOffsetX)-(r.containerWidth-i.activeTabWidth)/2,0,n)),void 0]}if("vertical"===o){var a=r.containerScrollHeight-r.containerHeight;return a<=0?[]:[void 0,Math.round((0,_bound.default)(r.containerScrollTop+(i
|