1 |
- import{d as u,x as g,r as y,y as S,w as h,a as n}from"./index-40af15f1.js";import{b as l}from"./index-7a5476f8.js";const x="_sticky_4d2w6_1",p="_white_4d2w6_6",k={sticky:x,white:p},_=u({name:"m-sticky",props:{position:{type:String,default:"top"},mode:{type:String,default:"fixed"},offsetTop:{type:String,default:"0px"},offsetBottom:{default:"0px"},varName:{type:String,default:"--header-height"}},emits:["barHeight"],setup(e,{slots:a,emit:m,expose:r}){const t=g({divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto",left:"0"}}),c=i=>{t.sectionStyle.height=`${i}px`,t.heightV=i,document.documentElement.style.setProperty(e.varName,`${i}px`),m("barHeight",i)},f=y(),d=y();S(()=>{e.position==="top"?t.divStyle.top=e.offsetTop||"0px":t.divStyle.bottom=e.offsetBottom||"0px";try{l(f.value,i=>{const s=i[0],{height:o}=s.contentRect;Math.abs(o-t.heightV)>1&&setTimeout(()=>{c(o)},10)})}catch(i){}});const v=()=>{try{l(d.value,i=>{const s=i[0],{height:o}=s.contentRect;Math.abs(o-t.heightV)>1&&setTimeout(()=>{c(o)},10)})}catch(i){}};return h(()=>e.offsetTop,()=>{t.divStyle.top=e.offsetTop}),h(()=>e.offsetBottom,()=>{t.divStyle.bottom=e.offsetBottom}),r({onChnageHeight:v}),()=>n("div",{style:[t.sectionStyle],class:e.mode==="sticky"&&k.sticky},[n("div",{ref:f,class:["van-sticky",t.heightV>0&&e.mode==="fixed"?"van-sticky--fixed":""],style:[t.divStyle,t.sectionStyle]},[n("div",{ref:d},[a.default&&a.default()])])])}});export{_ as M};
|