index-legacy-7dc60d9c.js 5.1 KB

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