index-legacy-aa826966.js 6.8 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){var n,i,r,u,o=[],l=!0,c=!1;try{if(r=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;l=!1}else for(;!(l=(n=r.call(a)).done)&&(o.push(n.value),o.length!==e);l=!0);}catch(v){c=!0,i=v}finally{try{if(!l&&null!=a.return&&(u=a.return(),Object(u)!==u))return}finally{if(c)throw i}}return o}}(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-2f8f4cf8.js"],(function(e,a){"use strict";var n,i,r,u,o,l,c,v,f,s,h,d,p,g,m,w,y,b,S,x,C,O,z,I,M,A,T,j,X;return{setters:[function(t){n=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.a5,s=t.e,h=t.X,d=t.w,p=t.aN,g=t.aU,m=t.b4,w=t.y,y=t.am,b=t.aO,S=t.an,x=t.ae,C=t.Y,O=t.a,z=t.aH,I=t.z,M=t.aa,A=t.p,T=t._,j=t.k,X=t.a8}],execute:function(){var a=t(n("swipe"),2),Y=a[0],k=a[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 a,n,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})),N=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(N.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 a=t.vertical?"height":"width",n=t.vertical?"width":"height";e[a]="".concat(W.value,"px"),e[n]=t[n]?"".concat(t[n],"px"):""}return e})),F=function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e*R.value;t.loop||(n=Math.min(n,-N.value));var i=a-n;return t.loop||(i=T(i,N.value,0)),i},G=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(!(H.value<=1)){var l=j.active,c=function(e){var a=j.active;return e?t.loop?T(a+e,-1,H.value):T(a+e,0,V.value):a}(n),v=F(c,u);if(t.loop){if(P[0]&&v!==N.value){var f=v<N.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)}},J=function(){j.swiping=!0,j.active<=-1?G({pace:H.value}):j.active>=H.value&&G({pace:-H.value})},K=function(){J(),Y.reset(),M((function(){j.swiping=!1,G({pace:1,emitChange:!0})}))},L=function(){return clearTimeout(a)},Q=function e(){L(),+t.autoplay>0&&H.value>1&&(a=setTimeout((function(){K(),e()}),+t.autoplay))},Z=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};j.rect=i,j.width=+(null!=(a=t.width)?a:i.width),j.height=+(null!=(n=t.height)?n: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()};z(u)?I().then(a):a()}},tt=function(){return Z(j.active)},et=function(e){!t.touchable||e.touches.length>1||(Y.start(e),X=!1,n=Date.now(),L(),J())},at=function(){if(t.touchable&&j.swiping){var e=Date.now()-n,a=U.value/e;if((Math.abs(a)>.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),G({pace:u,emitChange:!0})}else U.value&&G({pace:0});X=!1,j.swiping=!1,i("dragEnd",{index:$.value}),Q()}},nt=function(e,a){var n=a===$.value,i=n?{backgroundColor:t.indicatorColor}:void 0;return O("i",{style:i,class:k("indicator",{active:n})},null)};return h({prev:function(){J(),Y.reset(),M((function(){j.swiping=!1,G({pace:-1,emitChange:!0})}))},next:K,state:j,resize:tt,swipeTo:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};J(),Y.reset(),M((function(){var n;n=t.loop&&e===H.value?0===j.active?0:e:e%H.value,a.immediate?M((function(){j.swiping=!1})):j.swiping=!1,G({pace:n-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],tt),d(m(),(function(t){"visible"===t?Q():L()})),w(Z),y((function(){return Z(j.active)})),b((function(){return Z(j.active)})),S(L),x(L),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),G({offset:U.value}),X||(i("dragStart",{index:$.value}),X=!0))))}),{target:o}),function(){var e;return O("div",{ref:u,class:k()},[O("div",{ref:o,style:q.value,class:k("track",{vertical:t.vertical}),onTouchstartPassive:et,onTouchend:at,onTouchcancel:at},[null==(e=r.default)?void 0:e.call(r)]),r.indicator?r.indicator({active:$.value,total:H.value}):t.showIndicators&&H.value>1?O("div",{class:k("indicators",{vertical:t.vertical})},[Array(H.value).fill("").map(nt)]):void 0])}}}),B=(e("S",j(P)),t(n("swipe-item"),2)),H=B[0],R=B[1],U=o({name:H,setup:function(t,e){var a,n=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||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 w((function(){I((function(){i.mounted=!0}))})),h({setOffset:function(t){i.offset=t}}),function(){var t;return O("div",{class:R(),style:l.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",j(U))}}}))}();