index.4ddd16f0.js 1.4 KB

12
  1. import{d as o,_ as h,am as e,c as i}from"./index.ffe80dbe.js";const d="_sticky_4d2w6_1",n="_white_4d2w6_6";var s={sticky:d,white:n},l=o({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",h(()=>{setTimeout(()=>{const{height:t}=e(this.$refs.div);console.log(t,this.position),this.sectionStyle.height=`${t}px`,this.heightV=t,this.$emit("getHeight",t),console.log(t,"osticky height")},200),setTimeout(()=>{const{height:t}=e(this.$refs.div2);console.log(t,this.position,"next"),t!==this.heightV&&this.position==="top"&&(this.sectionStyle.height=`${t}px`,this.heightV=t,this.$emit("getHeight",t),console.log(t,"next osticky height"))},1e3)})},watch:{offsetTop(){this.divStyle.top=this.offsetTop},offsetBottom(){this.divStyle.bottom=this.offsetBottom}},render(){return i("div",{style:[this.sectionStyle],class:this.mode==="sticky"&&s.sticky},[i("div",{ref:"div",class:["van-sticky",this.mode==="fixed"?"van-sticky--fixed":"",s[this.background]],style:[this.divStyle,this.sectionStyle]},[i("div",{ref:"div2"},[this.$slots.default&&this.$slots.default()])])])}});export{l as O};