import{d as h,j as e}from"./ResizeObserver.es.45df6c0f.js";import{u as d}from"./index.f6378dda.js";const n="_white_1n1t5_1",a="_pad_1n1t5_4",r="_sticky_1n1t5_8";var i={white:n,pad:a,sticky:r,"white-only":"_white-only_1n1t5_13"},c=h({name:"col-sticky",props:{position:{type:String,default:"top"},background:{type:String,default:""},mode:{type:String,default:"fixed"},offsetTop:{type:String,default:"0px"},offsetBottom:{default:"0px"},varName:{type:String,default:"--header-height"}},emits:["getHeight"],data(){return{divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto"}}},mounted(){this.position==="top"?this.divStyle.top=this.offsetTop||"0px":this.divStyle.bottom=this.offsetBottom||"0px";try{d(this.$refs.div2,t=>{const o=t[0],{height:s}=o.contentRect;Math.abs(s-this.heightV)>1&&setTimeout(()=>{this.__initHeight(s)},10)})}catch(t){console.log(t,"error useResizeObserver")}},methods:{__initHeight(t){this.sectionStyle.height=`${t}px`,this.heightV=t,document.documentElement.style.setProperty(this.varName,`${t}px`),this.$emit("getHeight",t)}},watch:{offsetTop(){this.divStyle.top=this.offsetTop},offsetBottom(){this.divStyle.bottom=this.offsetBottom}},render(){return e("div",{style:[this.sectionStyle],class:this.mode==="sticky"&&i.sticky},[e("div",{ref:"div",class:["van-sticky",this.mode==="fixed"?"van-sticky--fixed":"",i[this.background]],style:[this.divStyle,this.sectionStyle]},[e("div",{ref:"div2"},[e("div",{class:i.pad},[this.$slots.default&&this.$slots.default()])])])])}});export{c as C};
