index-legacy.fab451f1.js 5.1 KB

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