1 |
- import{d as u,x as g,r as y,y as S,w as h,a as n}from"./index-869d77fb.js";import{d as l}from"./index-155c29c2.js";const x="_sticky_4d2w6_1",p="_white_4d2w6_6",k={sticky:x,white:p},b=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=o=>{t.sectionStyle.height=`${o}px`,t.heightV=o,document.documentElement.style.setProperty(e.varName,`${o}px`),m("barHeight",o)},f=y(),d=y();S(()=>{e.position==="top"?t.divStyle.top=e.offsetTop||"0px":t.divStyle.bottom=e.offsetBottom||"0px";try{l(f.value,o=>{const s=o[0],{height:i}=s.contentRect;Math.abs(i-t.heightV)>1&&setTimeout(()=>{c(i)},10)})}catch(o){}});const v=()=>{try{l(d.value,o=>{const s=o[0],{height:i}=s.contentRect;Math.abs(i-t.heightV)>1&&setTimeout(()=>{c(i)},10)})}catch(o){}};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",e.mode==="fixed"?"van-sticky--fixed":""],style:[t.divStyle,t.sectionStyle]},[n("div",{ref:d},[a.default&&a.default()])])])}});export{b as M};
|