index-legacy-40731e95.js 6.9 KB

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