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