1 |
- import{a3 as S,a8 as I,a4 as P,a9 as $,A as k,E as R,$ as T,aa as x,d as B,S as N,ab as O,Q as E,V as u,ac as V,I as j,ad as z,a2 as A,ae as C,j as p,af as H,X as h,ag as _,N as D}from"./index.394decd7.js";function F(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)},f=()=>{o.value&&r.unobserve(o.value)};I(f),P(f),$(n)}const[L,M]=k("sticky"),Q={zIndex:R,position:T("top"),container:Object,offsetTop:x(0),offsetBottom:x(0)};var U=B({name:L,props:Q,emits:["scroll","change"],setup(o,{emit:l,slots:r}){const n=N(),f=O(n),e=E({fixed:!1,width:0,height:0,transform:0}),i=u(()=>V(o.position==="top"?o.offsetTop:o.offsetBottom)),b=u(()=>{const{fixed:t,height:d,width:s}=e;if(t)return{width:`${s}px`,height:`${d}px`}}),g=u(()=>{if(!e.fixed)return;const t=j(z(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}),v=()=>{if(!n.value||H(n))return;const{container:t,position:d}=o,s=h(n),y=_(window);if(e.width=s.width,e.height=s.height,d==="top")if(t){const a=h(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=h(t),m=a-c.top-i.value-e.height;e.fixed=a-i.value<s.bottom&&a>c.top,e.transform=m<0?-m:0}else e.fixed=a-i.value<s.bottom}w(y)};return A(()=>e.fixed,t=>l("change",t)),C("scroll",v,{target:f}),F(n,v),()=>{var t;return p("div",{ref:n,style:b.value},[p("div",{class:M({fixed:e.fixed}),style:g.value},[(t=r.default)==null?void 0:t.call(r)])])}}});const Z=D(U);export{Z as S};
|