index-legacy-21793ce9.js 5.1 KB

1
  1. System.register(["./index-legacy-e5f315bc.js"],(function(e,t){"use strict";var a,i,l,o,n,u,r,v,s,c,h,p,d,f,g,w,m,b,y,x,S,C,$,z,M,T,k,I,Y;return{setters:[e=>{a=e.c,i=e.t,l=e.n,o=e.b,n=e.d,u=e.r,r=e.x,v=e.u,s=e.aa,c=e.e,h=e.Y,p=e.w,d=e.bk,f=e.bl,g=e.aS,w=e.y,m=e.au,b=e.aE,y=e.av,x=e.ar,S=e.Z,C=e.a,$=e.bJ,z=e.z,M=e.aG,T=e.p,k=e.$,I=e.k,Y=e.ad}],execute:function(){const[t,E]=a("swipe"),O={loop:i,width:l,height:l,vertical:Boolean,autoplay:o(0),duration:o(500),touchable:i,lazyRender:Boolean,initialSwipe:o(0),indicatorColor:String,showIndicators:i,stopPropagation:i},X=Symbol(t);var D=n({name:t,props:O,emits:["change","dragStart","dragEnd"],setup(e,{emit:t,slots:a}){const i=u(),l=u(),o=r({rect:null,width:0,height:0,offset:0,active:0,swiping:!1});let n=!1;const I=v(),{children:Y,linkChildren:O}=s(X),D=c((()=>Y.length)),P=c((()=>o[e.vertical?"height":"width"])),B=c((()=>e.vertical?I.deltaY.value:I.deltaX.value)),R=c((()=>o.rect?(e.vertical?o.rect.height:o.rect.width)-P.value*D.value:0)),j=c((()=>P.value?Math.ceil(Math.abs(R.value)/P.value):D.value)),A=c((()=>D.value*P.value)),G=c((()=>(o.active+D.value)%D.value)),H=c((()=>{const t=e.vertical?"vertical":"horizontal";return I.direction.value===t})),J=c((()=>{const t={transitionDuration:`${o.swiping?0:e.duration}ms`,transform:`translate${e.vertical?"Y":"X"}(${o.offset}px)`};if(P.value){const a=e.vertical?"height":"width",i=e.vertical?"width":"height";t[a]=`${A.value}px`,t[i]=e[i]?`${e[i]}px`:""}return t})),V=(t,a=0)=>{let i=t*P.value;e.loop||(i=Math.min(i,-R.value));let l=a-i;return e.loop||(l=k(l,R.value,0)),l},W=({pace:a=0,offset:i=0,emitChange:l})=>{if(D.value<=1)return;const{active:n}=o,u=(t=>{const{active:a}=o;return t?e.loop?k(a+t,-1,D.value):k(a+t,0,j.value):a})(a),r=V(u,i);if(e.loop){if(Y[0]&&r!==R.value){const e=r<R.value;Y[0].setOffset(e?A.value:0)}if(Y[D.value-1]&&0!==r){const e=r>0;Y[D.value-1].setOffset(e?-A.value:0)}}o.active=u,o.offset=r,l&&u!==n&&t("change",G.value)},Z=()=>{o.swiping=!0,o.active<=-1?W({pace:D.value}):o.active>=D.value&&W({pace:-D.value})},q=()=>{Z(),I.reset(),M((()=>{o.swiping=!1,W({pace:1,emitChange:!0})}))};let F;const K=()=>clearTimeout(F),L=()=>{K(),+e.autoplay>0&&D.value>1&&(F=setTimeout((()=>{q(),L()}),+e.autoplay))},N=(t=+e.initialSwipe)=>{if(!i.value)return;const a=()=>{var a,l;if(!$(i)){const t={width:i.value.offsetWidth,height:i.value.offsetHeight};o.rect=t,o.width=+(null!=(a=e.width)?a:t.width),o.height=+(null!=(l=e.height)?l:t.height)}D.value&&-1===(t=Math.min(D.value-1,t))&&(t=D.value-1),o.active=t,o.swiping=!0,o.offset=V(t),Y.forEach((e=>{e.setOffset(0)})),L()};$(i)?z().then(a):a()},Q=()=>N(o.active);let U;const _=t=>{!e.touchable||t.touches.length>1||(I.start(t),n=!1,U=Date.now(),K(),Z())},ee=()=>{if(!e.touchable||!o.swiping)return;const a=Date.now()-U,i=B.value/a;if((Math.abs(i)>.25||Math.abs(B.value)>P.value/2)&&H.value){const t=e.vertical?I.offsetY.value:I.offsetX.value;let a=0;a=e.loop?t>0?B.value>0?-1:1:0:-Math[B.value>0?"ceil":"floor"](B.value/P.value),W({pace:a,emitChange:!0})}else B.value&&W({pace:0});n=!1,o.swiping=!1,t("dragEnd",{index:G.value}),L()},te=(t,a)=>{const i=a===G.value,l=i?{backgroundColor:e.indicatorColor}:void 0;return C("i",{style:l,class:E("indicator",{active:i})},null)};return h({prev:()=>{Z(),I.reset(),M((()=>{o.swiping=!1,W({pace:-1,emitChange:!0})}))},next:q,state:o,resize:Q,swipeTo:(t,a={})=>{Z(),I.reset(),M((()=>{let i;i=e.loop&&t===D.value?0===o.active?0:t:t%D.value,a.immediate?M((()=>{o.swiping=!1})):o.swiping=!1,W({pace:i-o.active,emitChange:!0})}))}}),O({size:P,props:e,count:D,activeIndicator:G}),p((()=>e.initialSwipe),(e=>N(+e))),p(D,(()=>N(o.active))),p((()=>e.autoplay),L),p([d,f,()=>e.width,()=>e.height],Q),p(g(),(e=>{"visible"===e?L():K()})),w(N),m((()=>N(o.active))),b((()=>N(o.active))),y(K),x(K),S("touchmove",(a=>{e.touchable&&o.swiping&&(I.move(a),H.value)&&(!e.loop&&(0===o.active&&B.value>0||o.active===D.value-1&&B.value<0)||(T(a,e.stopPropagation),W({offset:B.value}),n||(t("dragStart",{index:G.value}),n=!0)))}),{target:l}),()=>{var t;return C("div",{ref:i,class:E()},[C("div",{ref:l,style:J.value,class:E("track",{vertical:e.vertical}),onTouchstartPassive:_,onTouchend:ee,onTouchcancel:ee},[null==(t=a.default)?void 0:t.call(a)]),a.indicator?a.indicator({active:G.value,total:D.value}):e.showIndicators&&D.value>1?C("div",{class:E("indicators",{vertical:e.vertical})},[Array(D.value).fill("").map(te)]):void 0])}}});e("S",I(D));const[P,B]=a("swipe-item");var R=n({name:P,setup(e,{slots:t}){let a;const i=r({offset:0,inited:!1,mounted:!1}),{parent:l,index:o}=Y(X);if(!l)return void console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");const n=c((()=>{const e={},{vertical:t}=l.props;return l.size.value&&(e[t?"height":"width"]=`${l.size.value}px`),i.offset&&(e.transform=`translate${t?"Y":"X"}(${i.offset}px)`),e})),u=c((()=>{const{loop:e,lazyRender:t}=l.props;if(!t||a)return!0;if(!i.mounted)return!1;const n=l.activeIndicator.value,u=l.count.value-1,r=0===n&&e?u:n-1,v=n===u&&e?0:n+1;return a=o.value===n||o.value===r||o.value===v,a}));return w((()=>{z((()=>{i.mounted=!0}))})),h({setOffset:e=>{i.offset=e}}),()=>{var e;return C("div",{class:B(),style:n.value},[u.value?null==(e=t.default)?void 0:e.call(t):null])}}});e("a",I(R))}}}));