index-69c03695.js 1.2 KB

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