UNPKG

quarkd

Version:

Mobile UI Components built on Web Components.

2 lines (1 loc) 2.22 kB
import{_ as t,a as e}from"../typeof.js";import{_ as n,a as i,b as o,c as r,P as c,H as s,d as f,N as a,B as l}from"../index2.js";import{_ as u}from"../defineProperty.js";import{v as p,r as d,b as v,p as y}from"../public.js";function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var o,r=n(t);if(e){var c=n(this).constructor;o=Reflect.construct(r,arguments,c)}else o=r.apply(this,arguments);return i(this,o)}}var R=function(n){o(f,s);var i=h(f);function f(){var e;t(this,f);for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return e=i.call.apply(i,[this].concat(o)),u(r(e),"offsettop","0vw"),u(r(e),"zindex","99"),u(r(e),"containerRef",c()),u(r(e),"stickyRef",c()),u(r(e),"calcSizeFuncRef",void 0),u(r(e),"scrollEvent",(function(){var t=e.containerRef.current,n=e.stickyRef.current;t&&n&&(t.style.height="".concat(t.getBoundingClientRect().height,"px"),e.calcSizeFuncRef&&t.getBoundingClientRect().top<=e.calcSizeFuncRef(e.offsettop)?(n.classList.add("sticky--fixed"),n.style.top=e.offsettop,n.style.zIndex=e.zindex):(n.classList.remove("sticky--fixed"),n.style=""))})),u(r(e),"getCalcEvent",(function(t){return t.includes("vw")?p:t.includes("rem")?d:t.includes("vh")?v:t.includes("%")?y:function(t){return Number(t.replace("px",""))}})),e}return e(f,[{key:"componentDidMount",value:function(){this.calcSizeFuncRef=this.getCalcEvent(this.offsettop),window.addEventListener("scroll",this.scrollEvent)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("scroll",this.scrollEvent)}},{key:"render",value:function(){return s.h("div",{id:"container",ref:this.containerRef,part:"root"},s.h("div",{ref:this.stickyRef,part:"sticky-ref"},s.h("slot",null)))}}]),f}();f([a()],R.prototype,"offsettop",void 0),f([a()],R.prototype,"zindex",void 0);var m=R=f([l({tag:"quark-sticky",style:":host {\n /* display: flex; */\n}\n\n.sticky--fixed {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 99;\n}\n"})],R);export{m as default};