index-legacy.5b7feeb6.js 6.6 KB

1
  1. !function(){function e(e,a){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,i,r=[],u=!0,o=!1;try{for(a=a.call(e);!(u=(n=a.next()).done)&&(r.push(n.value),!t||r.length!==t);u=!0);}catch(l){o=!0,i=l}finally{try{u||null==a.return||a.return()}finally{if(o)throw i}}return r}(e,a)||function(e,a){if(!e)return;if("string"==typeof e)return t(e,a);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,a)}(e,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 t(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}System.register(["./ResizeObserver.es-legacy.49c3e68e.js"],(function(t){"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(e){a=e.v,n=e.w,i=e.H,r=e.D,u=e.d,o=e.U,l=e.r,c=e.ar,v=e.E,f=e.G,s=e.Y,h=e.$,p=e.aT,d=e.aw,g=e.b2,m=e.a1,w=e.aU,y=e.aV,b=e.b3,S=e.ad,C=e.a2,x=e.c,z=e.aC,I=e.a0,M=e.a6,T=e.aZ,A=e.a_,O=e.z,Y=e.I}],execute:function(){var j=e(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(e,t){var a,n,i=t.emit,r=t.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[e.vertical?"height":"width"]})),B=f((function(){return e.vertical?j.deltaY.value:j.deltaX.value})),H=f((function(){return Y.rect?(e.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 t=e.vertical?"vertical":"horizontal";return j.direction.value===t})),Z=f((function(){var t={transitionDuration:"".concat(Y.swiping?0:e.duration,"ms"),transform:"translate".concat(e.vertical?"Y":"X","(").concat(Y.offset,"px)")};if(U.value){var a=e.vertical?"height":"width",n=e.vertical?"width":"height";t[a]="".concat($.value,"px"),t[n]=e[n]?"".concat(e[n],"px"):""}return t})),_=function(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t*U.value;e.loop||(n=Math.min(n,-H.value));var i=a-n;return e.loop||(i=A(i,H.value,0)),i},q=function(t){var a=t.pace,n=void 0===a?0:a,r=t.offset,u=void 0===r?0:r,o=t.emitChange;if(!(R.value<=1)){var l=Y.active,c=function(t){var a=Y.active;return t?e.loop?A(a+t,-1,R.value):A(a+t,0,V.value):a}(n),v=_(c,u);if(e.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 t(){K(),e.autoplay>0&&R.value>1&&(a=setTimeout((function(){J(),t()}),+e.autoplay))},N=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:+e.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=e.width)?a:i.width),Y.height=+(null!=(n=e.height)?n:i.height)}R.value&&(t=Math.min(R.value-1,t)),Y.active=t,Y.swiping=!0,Y.offset=_(t),k.forEach((function(e){e.setOffset(0)})),L()};z(u)?I().then(a):a()}},Q=function(){return N(Y.active)},ee=function(t){e.touchable&&(j.start(t),n=Date.now(),K(),F())},te=function(){if(e.touchable&&Y.swiping){var t=Date.now()-n,a=B.value/t;if((Math.abs(a)>.25||Math.abs(B.value)>U.value/2)&&W.value){var i=e.vertical?j.offsetY.value:j.offsetX.value,r=0;r=e.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()}},ae=function(t,a){var n=a===G.value,i=n?{backgroundColor:e.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(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};F(),j.reset(),T((function(){var n;n=e.loop&&t===R.value?0===Y.active?0:t:t%R.value,a.immediate?T((function(){Y.swiping=!1})):Y.swiping=!1,q({pace:n-Y.active,emitChange:!0})}))}}),P({size:U,props:e,count:R,activeIndicator:G}),h((function(){return e.initialSwipe}),(function(e){return N(+e)})),h(R,(function(){return N(Y.active)})),h((function(){return e.autoplay}),L),h([p,d],Q),h(g(),(function(e){"visible"===e?L():K()})),m(N),w((function(){return N(Y.active)})),y((function(){return N(Y.active)})),b(K),S(K),C("touchmove",(function(t){e.touchable&&Y.swiping&&(j.move(t),W.value&&(!e.loop&&(0===Y.active&&B.value>0||Y.active===R.value-1&&B.value<0)||(M(t,e.stopPropagation),q({offset:B.value}))))}),{target:O}),function(){var t;return x("div",{ref:u,class:X()},[x("div",{ref:O,style:Z.value,class:X("track",{vertical:e.vertical}),onTouchstartPassive:ee,onTouchend:te,onTouchcancel:te},[null==(t=r.default)?void 0:t.call(r)]),r.indicator?r.indicator({active:G.value,total:R.value}):e.showIndicators&&R.value>1?x("div",{class:X("indicators",{vertical:e.vertical})},[Array(R.value).fill("").map(ae)]):void 0])}}}),R=(t("S",O(P)),e(a("swipe-item"),2)),U=R[0],B=R[1],H=u({name:U,setup:function(e,t){var a,n=t.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 e={},t=u.props.vertical;return u.size.value&&(e[t?"height":"width"]="".concat(u.size.value,"px")),i.offset&&(e.transform="translate".concat(t?"Y":"X","(").concat(i.offset,"px)")),e})),v=f((function(){var e=u.props,t=e.loop;if(!e.lazyRender||a)return!0;if(!i.mounted)return!1;var n=u.activeIndicator.value,r=u.count.value-1,l=0===n&&t?r:n-1,c=n===r&&t?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(e){i.offset=e}}),function(){var e;return x("div",{class:B(),style:c.value},[v.value?null==(e=n.default)?void 0:e.call(n):null])}}console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.")}});t("a",O(H))}}}))}();