1 |
- System.register(["./index-legacy-e6be1dcb.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,I,T,O,X;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.ab,c=e.e,h=e.Z,p=e.w,d=e.bH,f=e.bI,g=e.aO,w=e.y,m=e.aX,b=e.bJ,y=e.aY,x=e.av,S=e._,C=e.a,z=e.bA,$=e.z,M=e.aS,I=e.p,T=e.a0,O=e.k,X=e.ae}],execute:function(){const[t,Y]=a("swipe"),k={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},D=Symbol(t);var E=n({name:t,props:k,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 O=v(),{children:X,linkChildren:k}=s(D),E=c((()=>X.length)),P=c((()=>o[e.vertical?"height":"width"])),A=c((()=>e.vertical?O.deltaY.value:O.deltaX.value)),B=c((()=>o.rect?(e.vertical?o.rect.height:o.rect.width)-P.value*E.value:0)),H=c((()=>P.value?Math.ceil(Math.abs(B.value)/P.value):E.value)),R=c((()=>E.value*P.value)),j=c((()=>(o.active+E.value)%E.value)),J=c((()=>{const t=e.vertical?"vertical":"horizontal";return O.direction.value===t})),V=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]=`${R.value}px`,t[i]=e[i]?`${e[i]}px`:""}return t})),W=(t,a=0)=>{let i=t*P.value;e.loop||(i=Math.min(i,-B.value));let l=a-i;return e.loop||(l=T(l,B.value,0)),l},Z=({pace:a=0,offset:i=0,emitChange:l})=>{if(E.value<=1)return;const{active:n}=o,u=(t=>{const{active:a}=o;return t?e.loop?T(a+t,-1,E.value):T(a+t,0,H.value):a})(a),r=W(u,i);if(e.loop){if(X[0]&&r!==B.value){const e=r<B.value;X[0].setOffset(e?R.value:0)}if(X[E.value-1]&&0!==r){const e=r>0;X[E.value-1].setOffset(e?-R.value:0)}}o.active=u,o.offset=r,l&&u!==n&&t("change",j.value)},_=()=>{o.swiping=!0,o.active<=-1?Z({pace:E.value}):o.active>=E.value&&Z({pace:-E.value})},q=()=>{_(),O.reset(),M((()=>{o.swiping=!1,Z({pace:1,emitChange:!0})}))};let F;const G=()=>clearTimeout(F),K=()=>{G(),+e.autoplay>0&&E.value>1&&(F=setTimeout((()=>{q(),K()}),+e.autoplay))},L=(t=+e.initialSwipe)=>{if(!i.value)return;const a=()=>{var a,l;if(!z(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)}E.value&&-1===(t=Math.min(E.value-1,t))&&(t=E.value-1),o.active=t,o.swiping=!0,o.offset=W(t),X.forEach((e=>{e.setOffset(0)})),K()};z(i)?$().then(a):a()},N=()=>L(o.active);let Q;const U=t=>{!e.touchable||t.touches.length>1||(O.start(t),n=!1,Q=Date.now(),G(),_())},ee=()=>{if(!e.touchable||!o.swiping)return;const a=Date.now()-Q,i=A.value/a;if((Math.abs(i)>.25||Math.abs(A.value)>P.value/2)&&J.value){const t=e.vertical?O.offsetY.value:O.offsetX.value;let a=0;a=e.loop?t>0?A.value>0?-1:1:0:-Math[A.value>0?"ceil":"floor"](A.value/P.value),Z({pace:a,emitChange:!0})}else A.value&&Z({pace:0});n=!1,o.swiping=!1,t("dragEnd",{index:j.value}),K()},te=(t,a)=>{const i=a===j.value,l=i?{backgroundColor:e.indicatorColor}:void 0;return C("i",{style:l,class:Y("indicator",{active:i})},null)};return h({prev:()=>{_(),O.reset(),M((()=>{o.swiping=!1,Z({pace:-1,emitChange:!0})}))},next:q,state:o,resize:N,swipeTo:(t,a={})=>{_(),O.reset(),M((()=>{let i;i=e.loop&&t===E.value?0===o.active?0:t:t%E.value,a.immediate?M((()=>{o.swiping=!1})):o.swiping=!1,Z({pace:i-o.active,emitChange:!0})}))}}),k({size:P,props:e,count:E,activeIndicator:j}),p((()=>e.initialSwipe),(e=>L(+e))),p(E,(()=>L(o.active))),p((()=>e.autoplay),K),p([d,f,()=>e.width,()=>e.height],N),p(g(),(e=>{"visible"===e?K():G()})),w(L),m((()=>L(o.active))),b((()=>L(o.active))),y(G),x(G),S("touchmove",(a=>{e.touchable&&o.swiping&&(O.move(a),J.value)&&(!e.loop&&(0===o.active&&A.value>0||o.active===E.value-1&&A.value<0)||(I(a,e.stopPropagation),Z({offset:A.value}),n||(t("dragStart",{index:j.value}),n=!0)))}),{target:l}),()=>{var t;return C("div",{ref:i,class:Y()},[C("div",{ref:l,style:V.value,class:Y("track",{vertical:e.vertical}),onTouchstartPassive:U,onTouchend:ee,onTouchcancel:ee},[null==(t=a.default)?void 0:t.call(a)]),a.indicator?a.indicator({active:j.value,total:E.value}):e.showIndicators&&E.value>1?C("div",{class:Y("indicators",{vertical:e.vertical})},[Array(E.value).fill("").map(te)]):void 0])}}});e("S",O(E));const[P,A]=a("swipe-item");var B=n({name:P,setup(e,{slots:t}){let a;const i=r({offset:0,inited:!1,mounted:!1}),{parent:l,index:o}=X(D);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((()=>{$((()=>{i.mounted=!0}))})),h({setOffset:e=>{i.offset=e}}),()=>{var e;return C("div",{class:A(),style:n.value},[u.value?null==(e=t.default)?void 0:e.call(t):null])}}});e("a",O(B))}}}));
|