"use strict";const s=require("../../../../common/vendor.js"),c=require("./props.js"),r=require("../../libs/mixin/mpMixin.js"),h=require("../../libs/mixin/mixin.js"),i=require("../../libs/function/index.js"),d=require("../../libs/config/zIndex.js"),u={name:"u-sticky",mixins:[r.mpMixin,h.mixin,c.props],data(){return{cssSticky:!1,stickyTop:0,elId:i.guid(),left:0,width:"auto",height:"auto",fixed:!1}},computed:{style(){const t={};return this.disabled?t.position="static":this.cssSticky?(t.position="sticky",t.zIndex=this.uZindex,t.top=i.addUnit(this.stickyTop)):t.height=this.fixed?this.height+"px":"auto",t.backgroundColor=this.bgColor,i.deepMerge(i.addStyle(this.customStyle),t)},stickyContent(){const t={};return this.cssSticky||(t.position=this.fixed?"fixed":"static",t.top=this.stickyTop+"px",t.left=this.left+"px",t.width=this.width=="auto"?"auto":this.width+"px",t.zIndex=this.uZindex),t},uZindex(){return this.zIndex?this.zIndex:d.zIndex.sticky}},mounted(){this.init()},methods:{init(){this.getStickyTop(),this.checkSupportCssSticky(),this.cssSticky||!this.disabled&&this.initObserveContent()},initObserveContent(){this.$uGetRect("#"+this.elId).then(t=>{this.height=t.height,this.left=t.left,this.width=t.width,this.$nextTick(()=>{this.observeContent()})})},observeContent(){this.disconnectObserver("contentObserver");const t=s.index.createIntersectionObserver({thresholds:[.95,.98,1]});t.relativeToViewport({top:-this.stickyTop}),t.observe(`#${this.elId}`,e=>{this.setFixed(e.boundingClientRect.top)}),this.contentObserver=t},offsetTop(t){const e=t<=this.stickyTop;this.fixed=e},disconnectObserver(t){const e=this[t];e&&e.disconnect()},getStickyTop(){console.log("this.offsetTop",this.offsetTop),this.stickyTop=i.getPx(this.offsetTop)+i.getPx(this.customNavHeight)},async checkSupportCssSticky(){i.os()==="android"&&Number(i.sys().system)>8&&(this.cssSticky=!0),this.cssSticky=await this.checkComputedStyle(),i.os()==="ios"&&(this.cssSticky=!0)},checkComputedStyle(){return new Promise(t=>{s.index.createSelectorQuery().in(this).select(".u-sticky").fields({computedStyle:["position"]}).exec(e=>{t(e[0].position==="sticky")})})},checkCssStickyForH5(){}},beforeUnmount(){this.disconnectObserver("contentObserver")}};function l(t,e,y,x,n,o){return{a:s.s(o.stickyContent),b:n.elId,c:s.s(o.style)}}const p=s._export_sfc(u,[["render",l],["__scopeId","data-v-8b303089"]]);wx.createComponent(p);
