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