/
home
/
maktab
/
pwa
/
assets
/
File Upload :
llllll
Current File: /home/maktab/pwa/assets/index-CwAQm-TQ.js
import{t as M,l as _,n as W,c as G,a as ue,L as re,x as ve,y as V,M as D,G as z,p as fe,F as de,N as he,w as K,b as me}from"./with-install-lbMbA8s-.js";import{a as ge,u as U,o as we}from"./use-touch-sX9psddV.js";import{d as Z,r as F,a as j,C as f,l as S,m as q,Z as pe,X as ye,Y as be,e as C,B as J}from"./index-CJHFPoO0.js";const[Q,I]=G("swipe"),Te={loop:M,width:W,height:W,vertical:Boolean,autoplay:_(0),duration:_(500),touchable:M,lazyRender:Boolean,initialSwipe:_(0),indicatorColor:String,showIndicators:M,stopPropagation:M},ee=Symbol(Q);var xe=Z({name:Q,props:Te,emits:["change"],setup(a,{emit:P,slots:h}){const u=F(),d=F(),e=j({rect:null,width:0,height:0,offset:0,active:0,swiping:!1}),r=ge(),{children:m,linkChildren:k}=ue(ee),i=f(()=>m.length),l=f(()=>e[a.vertical?"height":"width"]),s=f(()=>a.vertical?r.deltaY.value:r.deltaX.value),g=f(()=>e.rect?(a.vertical?e.rect.height:e.rect.width)-l.value*i.value:0),E=f(()=>Math.ceil(Math.abs(g.value)/l.value)),y=f(()=>i.value*l.value),$=f(()=>(e.active+i.value)%i.value),B=f(()=>{const t=a.vertical?"vertical":"horizontal";return r.direction.value===t}),te=f(()=>{const t={transitionDuration:`${e.swiping?0:a.duration}ms`,transform:`translate${a.vertical?"Y":"X"}(${e.offset}px)`};if(l.value){const o=a.vertical?"height":"width",n=a.vertical?"width":"height";t[o]=`${y.value}px`,t[n]=a[n]?`${a[n]}px`:""}return t}),ae=t=>{const{active:o}=e;return t?a.loop?D(o+t,-1,i.value):D(o+t,0,E.value):o},R=(t,o=0)=>{let n=t*l.value;a.loop||(n=Math.min(n,-g.value));let v=o-n;return a.loop||(v=D(v,g.value,0)),v},w=({pace:t=0,offset:o=0,emitChange:n})=>{if(i.value<=1)return;const{active:v}=e,c=ae(t),x=R(c,o);if(a.loop){if(m[0]&&x!==g.value){const O=x<g.value;m[0].setOffset(O?y.value:0)}if(m[i.value-1]&&x!==0){const O=x>0;m[i.value-1].setOffset(O?-y.value:0)}}e.active=c,e.offset=x,n&&c!==v&&P("change",$.value)},A=()=>{e.swiping=!0,e.active<=-1?w({pace:i.value}):e.active>=i.value&&w({pace:-i.value})},ie=()=>{A(),r.reset(),z(()=>{e.swiping=!1,w({pace:-1,emitChange:!0})})},Y=()=>{A(),r.reset(),z(()=>{e.swiping=!1,w({pace:1,emitChange:!0})})};let X;const b=()=>clearTimeout(X),T=()=>{b(),a.autoplay>0&&i.value>1&&(X=setTimeout(()=>{Y(),T()},+a.autoplay))},p=(t=+a.initialSwipe)=>{if(!u.value)return;const o=()=>{var n,v;if(!V(u)){const c={width:u.value.offsetWidth,height:u.value.offsetHeight};e.rect=c,e.width=+((n=a.width)!=null?n:c.width),e.height=+((v=a.height)!=null?v:c.height)}i.value&&(t=Math.min(i.value-1,t)),e.active=t,e.swiping=!0,e.offset=R(t),m.forEach(c=>{c.setOffset(0)}),T()};V(u)?J().then(o):o()},N=()=>p(e.active);let H;const ne=t=>{a.touchable&&(r.start(t),H=Date.now(),b(),A())},oe=t=>{a.touchable&&e.swiping&&(r.move(t),B.value&&(!a.loop&&(e.active===0&&s.value>0||e.active===i.value-1&&s.value<0)||(fe(t,a.stopPropagation),w({offset:s.value}))))},L=()=>{if(!a.touchable||!e.swiping)return;const t=Date.now()-H,o=s.value/t;if((Math.abs(o)>.25||Math.abs(s.value)>l.value/2)&&B.value){const v=a.vertical?r.offsetY.value:r.offsetX.value;let c=0;a.loop?c=v>0?s.value>0?-1:1:0:c=-Math[s.value>0?"ceil":"floor"](s.value/l.value),w({pace:c,emitChange:!0})}else s.value&&w({pace:0});e.swiping=!1,T()},se=(t,o={})=>{A(),r.reset(),z(()=>{let n;a.loop&&t===i.value?n=e.active===0?0:t:n=t%i.value,o.immediate?z(()=>{e.swiping=!1}):e.swiping=!1,w({pace:n-e.active,emitChange:!0})})},le=(t,o)=>{const n=o===$.value,v=n?{backgroundColor:a.indicatorColor}:void 0;return C("i",{style:v,class:I("indicator",{active:n})},null)},ce=()=>{if(h.indicator)return h.indicator({active:$.value,total:i.value});if(a.showIndicators&&i.value>1)return C("div",{class:I("indicators",{vertical:a.vertical})},[Array(i.value).fill("").map(le)])};return U({prev:ie,next:Y,state:e,resize:N,swipeTo:se}),k({size:l,props:a,count:i,activeIndicator:$}),S(()=>a.initialSwipe,t=>p(+t)),S(i,()=>p(e.active)),S(()=>a.autoplay,T),S([de,he],N),S(re(),t=>{t==="visible"?T():b()}),q(p),pe(()=>p(e.active)),we(()=>p(e.active)),ye(b),be(b),ve("touchmove",oe,{target:d}),()=>{var t;return C("div",{ref:u,class:I()},[C("div",{ref:d,style:te.value,class:I("track",{vertical:a.vertical}),onTouchstartPassive:ne,onTouchend:L,onTouchcancel:L},[(t=h.default)==null?void 0:t.call(h)]),ce()])}}});const ze=K(xe),[Se,Ce]=G("swipe-item");var Pe=Z({name:Se,setup(a,{slots:P}){let h;const u=j({offset:0,inited:!1,mounted:!1}),{parent:d,index:e}=me(ee);if(!d)return;const r=f(()=>{const i={},{vertical:l}=d.props;return d.size.value&&(i[l?"height":"width"]=`${d.size.value}px`),u.offset&&(i.transform=`translate${l?"Y":"X"}(${u.offset}px)`),i}),m=f(()=>{const{loop:i,lazyRender:l}=d.props;if(!l||h)return!0;if(!u.mounted)return!1;const s=d.activeIndicator.value,g=d.count.value-1,E=s===0&&i?g:s-1,y=s===g&&i?0:s+1;return h=e.value===s||e.value===E||e.value===y,h}),k=i=>{u.offset=i};return q(()=>{J(()=>{u.mounted=!0})}),U({setOffset:k}),()=>{var i;return C("div",{class:Ce(),style:r.value},[m.value?(i=P.default)==null?void 0:i.call(P):null])}}});const Ie=K(Pe);export{ze as S,Ie as a};
Copyright ©2k19 -
Hexid
|
Tex7ure