index-legacy.64e3b474.js 6.6 KB

1
  1. !function(){function t(t,a){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var n,i,r=[],u=!0,o=!1;try{for(a=a.call(t);!(u=(n=a.next()).done)&&(r.push(n.value),!e||r.length!==e);u=!0);}catch(l){o=!0,i=l}finally{try{u||null==a.return||a.return()}finally{if(o)throw i}}return r}(t,a)||function(t,a){if(!t)return;if("string"==typeof t)return e(t,a);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,a)}(t,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a<e;a++)n[a]=t[a];return n}System.register(["./index-legacy.90c82f08.js"],(function(e){"use strict";var a,n,i,r,u,o,l,c,v,f,s,h,p,d,g,m,w,y,b,S,x,C,z,A,I,M,T,O,Y;return{setters:[function(t){a=t.t,n=t.v,i=t.z,r=t.w,u=t.d,o=t.R,l=t.r,c=t.aq,v=t.x,f=t.y,s=t.W,h=t.Z,p=t.aN,d=t.au,g=t.aY,m=t.$,w=t.aO,y=t.aP,b=t.aZ,S=t.ab,x=t.a0,C=t.c,z=t.aA,A=t._,I=t.a4,M=t.aT,T=t.aU,O=t.D,Y=t.C}],execute:function(){var j=t(a("swipe"),2),D=j[0],P=j[1],X={loop:n,width:i,height:i,vertical:Boolean,autoplay:r(0),duration:r(500),touchable:n,lazyRender:Boolean,initialSwipe:r(0),indicatorColor:String,showIndicators:n,stopPropagation:n},k=Symbol(D),R=u({name:D,props:X,emits:["change"],setup:function(t,e){var a,n,i=e.emit,r=e.slots,u=o(),O=o(),Y=l({rect:null,width:0,height:0,offset:0,active:0,swiping:!1}),j=c(),D=v(k),X=D.children,R=D.linkChildren,B=f((function(){return X.length})),E=f((function(){return Y[t.vertical?"height":"width"]})),U=f((function(){return t.vertical?j.deltaY.value:j.deltaX.value})),W=f((function(){return Y.rect?(t.vertical?Y.rect.height:Y.rect.width)-E.value*B.value:0})),Z=f((function(){return E.value?Math.ceil(Math.abs(W.value)/E.value):B.value})),$=f((function(){return B.value*E.value})),q=f((function(){return(Y.active+B.value)%B.value})),H=f((function(){var e=t.vertical?"vertical":"horizontal";return j.direction.value===e})),N=f((function(){var e={transitionDuration:"".concat(Y.swiping?0:t.duration,"ms"),transform:"translate".concat(t.vertical?"Y":"X","(").concat(Y.offset,"px)")};if(E.value){var a=t.vertical?"height":"width",n=t.vertical?"width":"height";e[a]="".concat($.value,"px"),e[n]=t[n]?"".concat(t[n],"px"):""}return e})),V=function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e*E.value;t.loop||(n=Math.min(n,-W.value));var i=a-n;return t.loop||(i=T(i,W.value,0)),i},_=function(e){var a=e.pace,n=void 0===a?0:a,r=e.offset,u=void 0===r?0:r,o=e.emitChange;if(!(B.value<=1)){var l=Y.active,c=function(e){var a=Y.active;return e?t.loop?T(a+e,-1,B.value):T(a+e,0,Z.value):a}(n),v=V(c,u);if(t.loop){if(X[0]&&v!==W.value){var f=v<W.value;X[0].setOffset(f?$.value:0)}if(X[B.value-1]&&0!==v){var s=v>0;X[B.value-1].setOffset(s?-$.value:0)}}Y.active=c,Y.offset=v,o&&c!==l&&i("change",q.value)}},F=function(){Y.swiping=!0,Y.active<=-1?_({pace:B.value}):Y.active>=B.value&&_({pace:-B.value})},G=function(){F(),j.reset(),M((function(){Y.swiping=!1,_({pace:1,emitChange:!0})}))},J=function(){return clearTimeout(a)},K=function e(){J(),t.autoplay>0&&B.value>1&&(a=setTimeout((function(){G(),e()}),+t.autoplay))},L=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:+t.initialSwipe;if(u.value){var a=function(){var a,n;if(!z(u)){var i={width:u.value.offsetWidth,height:u.value.offsetHeight};Y.rect=i,Y.width=+(null!=(a=t.width)?a:i.width),Y.height=+(null!=(n=t.height)?n:i.height)}B.value&&(e=Math.min(B.value-1,e)),Y.active=e,Y.swiping=!0,Y.offset=V(e),X.forEach((function(t){t.setOffset(0)})),K()};z(u)?A().then(a):a()}},Q=function(){return L(Y.active)},tt=function(e){t.touchable&&(j.start(e),n=Date.now(),J(),F())},et=function(){if(t.touchable&&Y.swiping){var e=Date.now()-n,a=U.value/e;if((Math.abs(a)>.25||Math.abs(U.value)>E.value/2)&&H.value){var i=t.vertical?j.offsetY.value:j.offsetX.value,r=0;r=t.loop?i>0?U.value>0?-1:1:0:-Math[U.value>0?"ceil":"floor"](U.value/E.value),_({pace:r,emitChange:!0})}else U.value&&_({pace:0});Y.swiping=!1,K()}},at=function(e,a){var n=a===q.value,i=n?{backgroundColor:t.indicatorColor}:void 0;return C("i",{style:i,class:P("indicator",{active:n})},null)};return s({prev:function(){F(),j.reset(),M((function(){Y.swiping=!1,_({pace:-1,emitChange:!0})}))},next:G,state:Y,resize:Q,swipeTo:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};F(),j.reset(),M((function(){var n;n=t.loop&&e===B.value?0===Y.active?0:e:e%B.value,a.immediate?M((function(){Y.swiping=!1})):Y.swiping=!1,_({pace:n-Y.active,emitChange:!0})}))}}),R({size:E,props:t,count:B,activeIndicator:q}),h((function(){return t.initialSwipe}),(function(t){return L(+t)})),h(B,(function(){return L(Y.active)})),h((function(){return t.autoplay}),K),h([p,d],Q),h(g(),(function(t){"visible"===t?K():J()})),m(L),w((function(){return L(Y.active)})),y((function(){return L(Y.active)})),b(J),S(J),x("touchmove",(function(e){t.touchable&&Y.swiping&&(j.move(e),H.value&&(!t.loop&&(0===Y.active&&U.value>0||Y.active===B.value-1&&U.value<0)||(I(e,t.stopPropagation),_({offset:U.value}))))}),{target:O}),function(){var e;return C("div",{ref:u,class:P()},[C("div",{ref:O,style:N.value,class:P("track",{vertical:t.vertical}),onTouchstartPassive:tt,onTouchend:et,onTouchcancel:et},[null==(e=r.default)?void 0:e.call(r)]),r.indicator?r.indicator({active:q.value,total:B.value}):t.showIndicators&&B.value>1?C("div",{class:P("indicators",{vertical:t.vertical})},[Array(B.value).fill("").map(at)]):void 0])}}}),B=(e("S",O(R)),t(a("swipe-item"),2)),E=B[0],U=B[1],W=u({name:E,setup:function(t,e){var a,n=e.slots,i=l({offset:0,inited:!1,mounted:!1}),r=Y(k),u=r.parent,o=r.index;if(u){var c=f((function(){var t={},e=u.props.vertical;return u.size.value&&(t[e?"height":"width"]="".concat(u.size.value,"px")),i.offset&&(t.transform="translate".concat(e?"Y":"X","(").concat(i.offset,"px)")),t})),v=f((function(){var t=u.props,e=t.loop;if(!t.lazyRender||a)return!0;if(!i.mounted)return!1;var n=u.activeIndicator.value,r=u.count.value-1,l=0===n&&e?r:n-1,c=n===r&&e?0:n+1;return a=o.value===n||o.value===l||o.value===c}));return m((function(){A((function(){i.mounted=!0}))})),s({setOffset:function(t){i.offset=t}}),function(){var t;return C("div",{class:U(),style:c.value},[v.value?null==(t=n.default)?void 0:t.call(n):null])}}console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.")}});e("a",O(W))}}}))}();