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