1 |
- import{af as S,ao as k,ag as P,ap as I,x as $,E as z,S as R,U as m,d as T,W as B,aq as O,V as E,Z as u,ar as H,H as N,al as V,a2 as j,as as C,i as p,at as D,aj as v,au as U,D as Z}from"./index.9a8e7555.js";function _(o,l){if(!S||!window.IntersectionObserver)return;const r=new IntersectionObserver(e=>{l(e[0].intersectionRatio>0)},{root:document.body}),n=()=>{o.value&&r.observe(o.value)},d=()=>{o.value&&r.unobserve(o.value)};k(d),P(d),I(n)}const[q,A]=$("sticky"),F={zIndex:z,position:R("top"),container:Object,offsetTop:m(0),offsetBottom:m(0)};var L=T({name:q,props:F,emits:["scroll","change"],setup(o,{emit:l,slots:r}){const n=B(),d=O(n),e=E({fixed:!1,width:0,height:0,transform:0}),i=u(()=>H(o.position==="top"?o.offsetTop:o.offsetBottom)),b=u(()=>{const{fixed:t,height:f,width:s}=e;if(t)return{width:`${s}px`,height:`${f}px`}}),g=u(()=>{if(!e.fixed)return;const t=N(V(o.zIndex),{width:`${e.width}px`,height:`${e.height}px`,[o.position]:`${i.value}px`});return e.transform&&(t.transform=`translate3d(0, ${e.transform}px, 0)`),t}),w=t=>l("scroll",{scrollTop:t,isFixed:e.fixed}),h=()=>{if(!n.value||D(n))return;const{container:t,position:f}=o,s=v(n),y=U(window);if(e.width=s.width,e.height=s.height,f==="top")if(t){const a=v(t),c=a.bottom-i.value-e.height;e.fixed=i.value>s.top&&a.bottom>0,e.transform=c<0?c:0}else e.fixed=i.value>s.top;else{const{clientHeight:a}=document.documentElement;if(t){const c=v(t),x=a-c.top-i.value-e.height;e.fixed=a-i.value<s.bottom&&a>c.top,e.transform=x<0?-x:0}else e.fixed=a-i.value<s.bottom}w(y)};return j(()=>e.fixed,t=>l("change",t)),C("scroll",h,{target:d}),_(n,h),()=>{var t;return p("div",{ref:n,style:b.value},[p("div",{class:A({fixed:e.fixed}),style:g.value},[(t=r.default)==null?void 0:t.call(r)])])}}});const W=Z(L);export{W as S};
|