"use strict";const t=require("../common/src/instantiationDecorator.js"),e=require("./props.js"),s=require("../common/config.js"),i=require("../mixins/page-scroll.js"),o=require("../common/utils.js"),n=require("../common/utils.wxs.js"),r=require("../../../../common/vendor.js"),c=`${s.prefix}-sticky`,l=`.${c}`,a=t.uniComponent({name:c,options:{styleIsolation:"shared"},externalClasses:[`${s.prefix}-class`,`${s.prefix}-class-content`],mixins:[i.pageScrollMixin()],props:{...e.props},data:()=>({prefix:s.prefix,classPrefix:c,containerStyle:"",contentStyle:"",tools:n.tools}),watch:{offsetTop:"onScroll",disabled:"onScroll",container:"onScroll"},mounted(){this.onScroll()},methods:{onScroll(t){const{scrollTop:e}=t||{},{container:s,offsetTop:i,disabled:n}=this;n?this.setDataAfterDiff({isFixed:!1,transform:0}):(this.scrollTop=e||this.scrollTop,"function"!=typeof s?o.getRect(this,l).then((t=>{t&&(i>=t.top?(this.setDataAfterDiff({isFixed:!0,height:t.height}),this.transform=0):this.setDataAfterDiff({isFixed:!1}))})):Promise.all([o.getRect(this,l),this.getContainerRect()]).then((([t,e])=>{t&&e&&(i+t.height>e.height+e.top?this.setDataAfterDiff({isFixed:!1,transform:e.height-t.height}):i>=t.top?this.setDataAfterDiff({isFixed:!0,height:t.height,transform:0}):this.setDataAfterDiff({isFixed:!1,transform:0}))})))},setDataAfterDiff(t){const{offsetTop:e}=this,{containerStyle:s,contentStyle:i}=this,{isFixed:n,height:r,transform:c}=t;o.nextTick().then((()=>{let t="",o="";if(n&&(t+=`height:${r}px;`,o+=`position:fixed;top:${e}px;left:0;right:0;`),c){const t=`translate3d(0, ${c}px, 0)`;o+=`-webkit-transform:${t};transform:${t};`}s===t&&i===o||(this.containerStyle=t,this.contentStyle=o),this.$emit("scroll",{scrollTop:this.scrollTop,isFixed:n})}))},getContainerRect(){const t=this.container();return new Promise((e=>t.boundingClientRect(e).exec()))}}});const f=r._export_sfc(a,[["render",function(t,e,s,i,o,n){return{a:r.n(t.classPrefix+"__content "+t.tClassContent),b:r.s(t.tools._style(["z-index:"+t.zIndex,t.contentStyle])),c:r.n(t.classPrefix+" "+t.tClass),d:r.s(t.tools._style(["z-index:"+t.zIndex,t.containerStyle,t.customStyle]))}}],["__scopeId","data-v-ed32c77d"]]);wx.createComponent(f);
