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