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