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.48c8d62c.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,I,z,M,T,A,O,j;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.ao,v=t.x,f=t.y,s=t.W,h=t.Z,p=t.aI,d=t.aR,g=t.aS,m=t.$,w=t.aJ,y=t.aK,b=t.aT,S=t.ab,x=t.a0,C=t.c,I=t.at,z=t._,M=t.aP,T=t.a4,A=t.au,O=t.D,j=t.C}],execute:function(){var D=t(a("swipe"),2),P=D[0],R=D[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},Y=Symbol(P),k=u({name:P,props:X,emits:["change"],setup:function(t,e){var a,n,i=e.emit,r=e.slots,u=o(),O=o(),j=l({rect:null,width:0,height:0,offset:0,active:0,swiping:!1}),D=c(),P=v(Y),X=P.children,k=P.linkChildren,B=f((function(){return X.length})),E=f((function(){return j[t.vertical?"height":"width"]})),W=f((function(){return t.vertical?D.deltaY.value:D.deltaX.value})),$=f((function(){return j.rect?(t.vertical?j.rect.height:j.rect.width)-E.value*B.value:0})),H=f((function(){return E.value?Math.ceil(Math.abs($.value)/E.value):B.value})),J=f((function(){return B.value*E.value})),K=f((function(){return(j.active+B.value)%B.value})),U=f((function(){var e=t.vertical?"vertical":"horizontal";return D.direction.value===e})),V=f((function(){var e={transitionDuration:"".concat(j.swiping?0:t.duration,"ms"),transform:"translate".concat(t.vertical?"Y":"X","(").concat(j.offset,"px)")};if(E.value){var a=t.vertical?"height":"width",n=t.vertical?"width":"height";e[a]="".concat(J.value,"px"),e[n]=t[n]?"".concat(t[n],"px"):""}return e})),Z=function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e*E.value;t.loop||(n=Math.min(n,-$.value));var i=a-n;return t.loop||(i=A(i,$.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=j.active,c=function(e){var a=j.active;return e?t.loop?A(a+e,-1,B.value):A(a+e,0,H.value):a}(n),v=Z(c,u);if(t.loop){if(X[0]&&v!==$.value){var f=v<$.value;X[0].setOffset(f?J.value:0)}if(X[B.value-1]&&0!==v){var s=v>0;X[B.value-1].setOffset(s?-J.value:0)}}j.active=c,j.offset=v,o&&c!==l&&i("change",K.value)}},q=function(){j.swiping=!0,j.active<=-1?_({pace:B.value}):j.active>=B.value&&_({pace:-B.value})},F=function(){q(),D.reset(),M((function(){j.swiping=!1,_({pace:1,emitChange:!0})}))},G=function(){return clearTimeout(a)},L=function e(){G(),t.autoplay>0&&B.value>1&&(a=setTimeout((function(){F(),e()}),+t.autoplay))},N=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:+t.initialSwipe;if(u.value){var a=function(){var a,n;if(!I(u)){var i={width:u.value.offsetWidth,height:u.value.offsetHeight};j.rect=i,j.width=+(null!=(a=t.width)?a:i.width),j.height=+(null!=(n=t.height)?n:i.height)}B.value&&(e=Math.min(B.value-1,e)),j.active=e,j.swiping=!0,j.offset=Z(e),X.forEach((function(t){t.setOffset(0)})),L()};I(u)?z().then(a):a()}},Q=function(){return N(j.active)},tt=function(e){t.touchable&&(D.start(e),n=Date.now(),G(),q())},et=function(){if(t.touchable&&j.swiping){var e=Date.now()-n,a=W.value/e;if((Math.abs(a)>.25||Math.abs(W.value)>E.value/2)&&U.value){var i=t.vertical?D.offsetY.value:D.offsetX.value,r=0;r=t.loop?i>0?W.value>0?-1:1:0:-Math[W.value>0?"ceil":"floor"](W.value/E.value),_({pace:r,emitChange:!0})}else W.value&&_({pace:0});j.swiping=!1,L()}},at=function(e,a){var n=a===K.value,i=n?{backgroundColor:t.indicatorColor}:void 0;return C("i",{style:i,class:R("indicator",{active:n})},null)};return s({prev:function(){q(),D.reset(),M((function(){j.swiping=!1,_({pace:-1,emitChange:!0})}))},next:F,state:j,resize:Q,swipeTo:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};q(),D.reset(),M((function(){var n;n=t.loop&&e===B.value?0===j.active?0:e:e%B.value,a.immediate?M((function(){j.swiping=!1})):j.swiping=!1,_({pace:n-j.active,emitChange:!0})}))}}),k({size:E,props:t,count:B,activeIndicator:K}),h((function(){return t.initialSwipe}),(function(t){return N(+t)})),h(B,(function(){return N(j.active)})),h((function(){return t.autoplay}),L),h([p,d],Q),h(g(),(function(t){"visible"===t?L():G()})),m(N),w((function(){return N(j.active)})),y((function(){return N(j.active)})),b(G),S(G),x("touchmove",(function(e){t.touchable&&j.swiping&&(D.move(e),U.value&&(!t.loop&&(0===j.active&&W.value>0||j.active===B.value-1&&W.value<0)||(T(e,t.stopPropagation),_({offset:W.value}))))}),{target:O}),function(){var e;return C("div",{ref:u,class:R()},[C("div",{ref:O,style:V.value,class:R("track",{vertical:t.vertical}),onTouchstartPassive:tt,onTouchend:et,onTouchcancel:et},[null==(e=r.default)?void 0:e.call(r)]),r.indicator?r.indicator({active:K.value,total:B.value}):t.showIndicators&&B.value>1?C("div",{class:R("indicators",{vertical:t.vertical})},[Array(B.value).fill("").map(at)]):void 0])}}}),B=(e("S",O(k)),t(a("swipe-item"),2)),E=B[0],W=B[1],$=u({name:E,setup:function(t,e){var a,n=e.slots,i=l({offset:0,inited:!1,mounted:!1}),r=j(Y),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(){z((function(){i.mounted=!0}))})),s({setOffset:function(t){i.offset=t}}),function(){var t;return C("div",{class:W(),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($))}}}))}();
|