1 |
- import{c as w,b as g,n as A,d as D,r as x,bB as B,x as _,u as F,w as m,Z as L,a as o,L as M,z as N,bG as $,p as q,k as U,F as W,A as G}from"./index-5e5e4ebc.js";const[I,f,Y]=w("pull-refresh"),V=50,z=["pulling","loosing","success"],C={disabled:Boolean,modelValue:Boolean,headHeight:g(V),successText:String,pullingText:String,loosingText:String,loadingText:String,pullDistance:A,successDuration:g(500),animationDuration:g(300)};var X=D({name:I,props:C,emits:["change","refresh","update:modelValue"],setup(a,{emit:i,slots:n}){let l;const u=x(),T=x(),H=B(u),t=_({status:"normal",distance:0,duration:0}),r=F(),k=()=>{if(a.headHeight!==V)return{height:`${a.headHeight}px`}},h=()=>t.status!=="loading"&&t.status!=="success"&&!a.disabled,P=e=>{const s=+(a.pullDistance||a.headHeight);return e>s&&(e<s*2?e=s+(e-s)/2:e=s*1.5+(e-s*2)/4),Math.round(e)},c=(e,s)=>{const d=+(a.pullDistance||a.headHeight);t.distance=e,s?t.status="loading":e===0?t.status="normal":e<d?t.status="pulling":t.status="loosing",i("change",{status:t.status,distance:e})},S=()=>{const{status:e}=t;return e==="normal"?"":a[`${e}Text`]||Y(e)},R=()=>{const{status:e,distance:s}=t;if(n[e])return n[e]({distance:s});const d=[];return z.includes(e)&&d.push(o("div",{class:f("text")},[S()])),e==="loading"&&d.push(o(M,{class:f("loading")},{default:S})),d},b=()=>{t.status="success",setTimeout(()=>{c(0)},+a.successDuration)},p=e=>{l=$(H.value)===0,l&&(t.duration=0,r.start(e))},y=e=>{h()&&p(e)},E=e=>{if(h()){l||p(e);const{deltaY:s}=r;r.move(e),l&&s.value>=0&&r.isVertical()&&(q(e),c(P(s.value)))}},v=()=>{l&&r.deltaY.value&&h()&&(t.duration=+a.animationDuration,t.status==="loosing"?(c(+a.headHeight,!0),i("update:modelValue",!0),N(()=>i("refresh"))):c(0))};return m(()=>a.modelValue,e=>{t.duration=+a.animationDuration,e?c(+a.headHeight,!0):n.success||a.successText?b():c(0,!1)}),L("touchmove",E,{target:T}),()=>{var e;const s={transitionDuration:`${t.duration}ms`,transform:t.distance?`translate3d(0,${t.distance}px, 0)`:""};return o("div",{ref:u,class:f()},[o("div",{ref:T,class:f("track"),style:s,onTouchstartPassive:y,onTouchend:v,onTouchcancel:v},[o("div",{class:f("head"),style:k()},[R()]),(e=n.default)==null?void 0:e.call(n)])])}}});const Z=U(X),j="_animateWrap_1kuq9_1",J="_loading_1kuq9_5",K="_pullRefresh_1kuq9_13",O={animateWrap:j,loading:J,pullRefresh:K};const ee=D({name:"m-full-refresh",props:{title:String,modelValue:{type:Boolean,default:!1}},emits:["refresh","update:modelValue"],setup(a,{emit:i,slots:n}){const l=_({fullState:!1});return m(()=>a.modelValue,u=>{l.fullState=u}),m(()=>l.fullState,u=>{i("update:modelValue",u)}),()=>o(Z,{modelValue:l.fullState,"onUpdate:modelValue":u=>l.fullState=u,onRefresh:()=>i("refresh"),loadingText:" ",class:O.pullRefresh},{default:()=>o(W,null,[G(" "),n.default&&n.default()])})}});export{ee as M};
|