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