index-legacy-4158ad15.js 5.1 KB

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