index-6b314488.js 1.2 KB

12
  1. import{d as m,O as v,i as n,o as r,Y as u,w as a,g as o}from"./index-1d4a9afa.js";const h="_sticky_4d2w6_1",S="_white_4d2w6_6",g={sticky:h,white:S},k=m({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(t,{slots:s,emit:c}){const e=v({divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto",left:"0"}}),y=i=>{e.sectionStyle.height=`${i}px`,e.heightV=i,document.documentElement.style.setProperty(t.varName,`${i}px`),c("barHeight",i)},f=n(),d=n();return r(()=>{t.position==="top"?e.divStyle.top=t.offsetTop||"0px":e.divStyle.bottom=t.offsetBottom||"0px",new ResizeObserver(()=>{const{height:l}=u(d.value);y(l)}).observe(f.value)}),a(()=>t.offsetTop,()=>{e.divStyle.top=t.offsetTop}),a(()=>t.offsetBottom,()=>{e.divStyle.bottom=t.offsetBottom}),()=>o("div",{style:[e.sectionStyle],class:t.mode==="sticky"&&g.sticky},[o("div",{ref:f,class:["van-sticky",t.mode==="fixed"?"van-sticky--fixed":""],style:[e.divStyle,e.sectionStyle]},[o("div",{ref:d},[s.default&&s.default()])])])}});export{k as M};