index-legacy-1bbc9b34.js 5.1 KB

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