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