import{d as h,_ as d,an as e,c as s}from"./index.d1dca38b.js";const f="_sticky_4d2w6_1",n="_white_4d2w6_6";var o={sticky:f,white:n},c=h({emits:["getHeight"],name:"o-sticky",props:{position:{type:String,default:"top"},background:{type:String,default:""},mode:{type:String,default:"fixed"},offsetTop:{type:String,default:"0px"},offsetBottom:{default:"0px"}},data(){return{divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto",left:"0"}}},mounted(){this.position==="top"?this.divStyle.top=this.offsetTop||"0px":this.divStyle.bottom=this.offsetBottom||"0px",d(()=>{const{height:t}=e(this.$refs.div);this.__initHeight(t),setTimeout(()=>{const{height:i}=e(this.$refs.div);this.__initHeight(i)},200),setTimeout(()=>{const{height:i}=e(this.$refs.div2);i!==this.heightV&&this.position==="top"&&this.__initHeight(i)},1e3)})},methods:{__initHeight(t){this.sectionStyle.height=`${t}px`,this.heightV=t,this.$emit("getHeight",t)}},watch:{offsetTop(){this.divStyle.top=this.offsetTop},offsetBottom(){this.divStyle.bottom=this.offsetBottom}},render(){return s("div",{style:[this.sectionStyle],class:this.mode==="sticky"&&o.sticky},[s("div",{ref:"div",class:["van-sticky",this.mode==="fixed"?"van-sticky--fixed":"",o[this.background]],style:[this.divStyle,this.sectionStyle]},[s("div",{ref:"div2"},[this.$slots.default&&this.$slots.default()])])])}});export{c as O};
