You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
4.9 KiB
2 lines
4.9 KiB
import{j as W,k as j,a as F,l as Q,m as ge,n as we,q as c,s as U,v as C,x as me,y as ye,z as be,o as V,A as xe,B as ze,C as Ce,D as Me,E as $e,b as M,G as O,H as Z,I as X,J as ee,K as te,L as P,M as Se,N as Y,O as ae,P as Te,__tla as _e}from"./index.3b792103.js";let ie,le,Oe=Promise.all([(()=>{try{return _e}catch{}})()]).then(async()=>{const[A,$]=W("swipe"),se={loop:O,width:Z,height:Z,vertical:Boolean,autoplay:X(0),duration:X(500),touchable:O,lazyRender:Boolean,initialSwipe:X(0),indicatorColor:String,showIndicators:O,stopPropagation:O},B=Symbol(A);var oe=j({name:A,props:se,emits:["change"],setup(a,{emit:S,slots:f}){const r=F(),h=F(),e=Q({rect:null,width:0,height:0,offset:0,active:0,swiping:!1}),u=ge(),{children:d,linkChildren:k}=we(B),i=c(()=>d.length),n=c(()=>e[a.vertical?"height":"width"]),o=c(()=>a.vertical?u.deltaY.value:u.deltaX.value),g=c(()=>e.rect?(a.vertical?e.rect.height:e.rect.width)-n.value*i.value:0),I=c(()=>n.value?Math.ceil(Math.abs(g.value)/n.value):i.value),y=c(()=>i.value*n.value),T=c(()=>(e.active+i.value)%i.value),R=c(()=>{const t=a.vertical?"vertical":"horizontal";return u.direction.value===t}),ve=c(()=>{const t={transitionDuration:`${e.swiping?0:a.duration}ms`,transform:`translate${a.vertical?"Y":"X"}(${e.offset}px)`};if(n.value){const s=a.vertical?"height":"width",l=a.vertical?"width":"height";t[s]=`${y.value}px`,t[l]=a[l]?`${a[l]}px`:""}return t}),re=t=>{const{active:s}=e;return t?a.loop?Y(s+t,-1,i.value):Y(s+t,0,I.value):s},q=(t,s=0)=>{let l=t*n.value;a.loop||(l=Math.min(l,-g.value));let v=s-l;return a.loop||(v=Y(v,g.value,0)),v},w=({pace:t=0,offset:s=0,emitChange:l})=>{if(i.value<=1)return;const{active:v}=e,p=re(t),z=q(p,s);if(a.loop){if(d[0]&&z!==g.value){const D=z<g.value;d[0].setOffset(D?y.value:0)}if(d[i.value-1]&&z!==0){const D=z>0;d[i.value-1].setOffset(D?-y.value:0)}}e.active=p,e.offset=z,l&&p!==v&&S("change",T.value)},_=()=>{e.swiping=!0,e.active<=-1?w({pace:i.value}):e.active>=i.value&&w({pace:-i.value})},ue=()=>{_(),u.reset(),P(()=>{e.swiping=!1,w({pace:-1,emitChange:!0})})},G=()=>{_(),u.reset(),P(()=>{e.swiping=!1,w({pace:1,emitChange:!0})})};let J;const b=()=>clearTimeout(J),x=()=>{b(),a.autoplay>0&&i.value>1&&(J=setTimeout(()=>{G(),x()},+a.autoplay))},m=(t=+a.initialSwipe)=>{if(!r.value)return;const s=()=>{var l,v;if(!ee(r)){const p={width:r.value.offsetWidth,height:r.value.offsetHeight};e.rect=p,e.width=+((l=a.width)!=null?l:p.width),e.height=+((v=a.height)!=null?v:p.height)}i.value&&(t=Math.min(i.value-1,t)),e.active=t,e.swiping=!0,e.offset=q(t),d.forEach(p=>{p.setOffset(0)}),x()};ee(r)?te().then(s):s()},K=()=>m(e.active);let L;const ce=t=>{!a.touchable||(u.start(t),L=Date.now(),b(),_())},he=t=>{a.touchable&&e.swiping&&(u.move(t),R.value&&(!a.loop&&(e.active===0&&o.value>0||e.active===i.value-1&&o.value<0)||(Se(t,a.stopPropagation),w({offset:o.value}))))},N=()=>{if(!a.touchable||!e.swiping)return;const t=Date.now()-L,s=o.value/t;if((Math.abs(s)>.25||Math.abs(o.value)>n.value/2)&&R.value){const l=a.vertical?u.offsetY.value:u.offsetX.value;let v=0;a.loop?v=l>0?o.value>0?-1:1:0:v=-Math[o.value>0?"ceil":"floor"](o.value/n.value),w({pace:v,emitChange:!0})}else o.value&&w({pace:0});e.swiping=!1,x()},pe=(t,s={})=>{_(),u.reset(),P(()=>{let l;a.loop&&t===i.value?l=e.active===0?0:t:l=t%i.value,s.immediate?P(()=>{e.swiping=!1}):e.swiping=!1,w({pace:l-e.active,emitChange:!0})})},fe=(t,s)=>{const l=s===T.value,v=l?{backgroundColor:a.indicatorColor}:void 0;return M("i",{style:v,class:$("indicator",{active:l})},null)},de=()=>{if(f.indicator)return f.indicator({active:T.value,total:i.value});if(a.showIndicators&&i.value>1)return M("div",{class:$("indicators",{vertical:a.vertical})},[Array(i.value).fill("").map(fe)])};return U({prev:ue,next:G,state:e,resize:K,swipeTo:pe}),k({size:n,props:a,count:i,activeIndicator:T}),C(()=>a.initialSwipe,t=>m(+t)),C(i,()=>m(e.active)),C(()=>a.autoplay,x),C([me,ye],K),C(be(),t=>{t==="visible"?x():b()}),V(m),xe(()=>m(e.active)),ze(()=>m(e.active)),Ce(b),Me(b),$e("touchmove",he,{target:h}),()=>{var t;return M("div",{ref:r,class:$()},[M("div",{ref:h,style:ve.value,class:$("track",{vertical:a.vertical}),onTouchstartPassive:ce,onTouchend:N,onTouchcancel:N},[(t=f.default)==null?void 0:t.call(f)]),de()])}}});let E,H;le=ae(oe),[E,H]=W("swipe-item");var ne=j({name:E,setup(a,{slots:S}){let f;const r=Q({offset:0,inited:!1,mounted:!1}),{parent:h,index:e}=Te(B);if(!h)return;const u=c(()=>{const i={},{vertical:n}=h.props;return h.size.value&&(i[n?"height":"width"]=`${h.size.value}px`),r.offset&&(i.transform=`translate${n?"Y":"X"}(${r.offset}px)`),i}),d=c(()=>{const{loop:i,lazyRender:n}=h.props;if(!n||f)return!0;if(!r.mounted)return!1;const o=h.activeIndicator.value,g=h.count.value-1,I=o===0&&i?g:o-1,y=o===g&&i?0:o+1;return f=e.value===o||e.value===I||e.value===y,f}),k=i=>{r.offset=i};return V(()=>{te(()=>{r.mounted=!0})}),U({setOffset:k}),()=>{var i;return M("div",{class:H(),style:u.value},[d.value?(i=S.default)==null?void 0:i.call(S):null])}}});ie=ae(ne)});export{ie as S,Oe as __tla,le as a};
|