1 |
- import{E as k,ab as h,G as _,d as y,U as $,ac as w,S as A,ai as N,a3 as U,j as c,aT as p,aq as B,X as G,ah as I,O as L}from"./ResizeObserver.es.39b48a47.js";const[M,r,R]=k("pull-refresh"),v=50,X=["pulling","loosing","success"],Y={disabled:Boolean,modelValue:Boolean,headHeight:h(v),successText:String,pullingText:String,loosingText:String,loadingText:String,pullDistance:_,successDuration:h(500),animationDuration:h(300)};var j=y({name:M,props:Y,emits:["refresh","update:modelValue"],setup(s,{emit:f,slots:o}){let u;const g=$(),D=w(g),e=A({status:"normal",distance:0,duration:0}),i=N(),x=()=>{if(s.headHeight!==v)return{height:`${s.headHeight}px`}},d=()=>e.status!=="loading"&&e.status!=="success"&&!s.disabled,H=t=>{const a=+(s.pullDistance||s.headHeight);return t>a&&(t<a*2?t=a+(t-a)/2:t=a*1.5+(t-a*2)/4),Math.round(t)},n=(t,a)=>{const l=+(s.pullDistance||s.headHeight);e.distance=t,a?e.status="loading":t===0?e.status="normal":t<l?e.status="pulling":e.status="loosing"},T=()=>{const{status:t}=e;return t==="normal"?"":s[`${t}Text`]||R(t)},P=()=>{const{status:t,distance:a}=e;if(o[t])return o[t]({distance:a});const l=[];return X.includes(t)&&l.push(c("div",{class:r("text")},[T()])),t==="loading"&&l.push(c(p,{class:r("loading")},{default:T})),l},E=()=>{e.status="success",setTimeout(()=>{n(0)},+s.successDuration)},m=t=>{u=I(D.value)===0,u&&(e.duration=0,i.start(t))},V=t=>{d()&&m(t)},b=t=>{if(d()){u||m(t);const{deltaY:a}=i;i.move(t),u&&a.value>=0&&i.isVertical()&&(B(t),n(H(a.value)))}},S=()=>{u&&i.deltaY.value&&d()&&(e.duration=+s.animationDuration,e.status==="loosing"?(n(+s.headHeight,!0),f("update:modelValue",!0),G(()=>f("refresh"))):n(0))};return U(()=>s.modelValue,t=>{e.duration=+s.animationDuration,t?n(+s.headHeight,!0):o.success||s.successText?E():n(0,!1)}),()=>{var t;const a={transitionDuration:`${e.duration}ms`,transform:e.distance?`translate3d(0,${e.distance}px, 0)`:""};return c("div",{ref:g,class:r()},[c("div",{class:r("track"),style:a,onTouchstart:V,onTouchmove:b,onTouchend:S,onTouchcancel:S},[c("div",{class:r("head"),style:x()},[P()]),(t=o.default)==null?void 0:t.call(o)])])}}});const C=L(j);export{C as P};
|