1/*! Copyright (c) Safe As Milk. All rights reserved. */import{debounce}from"utils";class StickyScroll extends HTMLElement{#ticking;#topGap;#maxDisplacement;#scrollPosition;#intersectionObserver;#topPosition;constructor(){super(),this.#topGap=18,this.#intersectionObserver=null}connectedCallback(){const scrollListener=()=>{this.#ticking||(window.requestAnimationFrame((()=>{this.#setStickyDisplacement(),this.#ticking=!1})),this.#ticking=!0)},handleIntersection=entries=>{entries.forEach((entry=>{entry.isIntersecting?window.addEventListener("scroll",scrollListener):window.removeEventListener("scroll",scrollListener)}))},updateMaxDisplacement=()=>{const getHeightWithBottomMargin=()=>{if(Number(window.getComputedStyle(this).getPropertyValue("padding-bottom").replace("px","")))return this.offsetHeight;{this.style.paddingBottom="1px";const fullHeight=this.offsetHeight-1;return this.style.paddingBottom=null,fullHeight}};this.#maxDisplacement=window.innerHeight-getHeightWithBottomMargin()-18},updateObserver=()=>{this.#setTopGap(),this.#topPosition||(this.#topPosition=this.#topGap),updateMaxDisplacement(),this.#scrollPosition=window.scrollY,this.#setStyles(),window.innerHeight<this.offsetHeight?(this.#intersectionObserver||(this.#intersectionObserver=new IntersectionObserver(handleIntersection.bind(this),{rootMargin:"0px"})),this.#intersectionObserver.observe(this),this.classList.add("is-scrollable"),this.classList.remove("is-not-scrollable")):window.innerHeight>=this.offsetHeight&&this.#intersectionObserver&&(this.#intersectionObserver.disconnect(),window.removeEventListener("scroll",scrollListener),this.classList.add("is-not-scrollable"),this.classList.remove("is-scrollable"))};updateObserver(),window.addEventListener("resize",debounce(updateObserver,100)),new ResizeObserver(debounce(updateObserver,100)).observe(this)}#setTopGap(){const header=document.querySelector("header");this.#topGap=header.getAttribute("data-sticky-header")==="true"?header.offsetHeight+18:18}#setStyles(){this.style.display="block",this.style.position="sticky",this.style.top=`${this.#topPosition}px`,this.classList.add("is-not-scrollable")}#setStickyDisplacement(){const stickyElementTop=Number(this.style.top.replace("px",""));if(window.scrollY<this.#scrollPosition)if(stickyElementTop<this.#topGap){const topMath=stickyElementTop+this.#scrollPosition-window.scrollY;this.style.top=`${topMath}px`,this.#topPosition=topMath,topMath>=this.#topGap&&(this.style.top=`${this.#topGap}px`,this.#topPosition=this.#topGap)}else stickyElementTop>=this.#topGap&&(this.style.top=`${this.#topGap}px`,this.#topPosition=this.#topGap);else if(stickyElementTop>this.#maxDisplacement){const topMath=stickyElementTop+this.#scrollPosition-window.scrollY;this.style.top=`${topMath}px`,this.#topPosition=topMath,topMath<=this.#maxDisplacement&&(this.style.top=`${this.#maxDisplacement}px`,this.#topPosition=this.#maxDisplacement)}else stickyElementTop<=this.#maxDisplacement&&(this.style.top=`${this.#maxDisplacement}px`,this.#topPosition=this.#maxDisplacement);this.#scrollPosition=window.scrollY}}customElements.define("sticky-scroll",StickyScroll); 2//# sourceMappingURL=/cdn/shop/t/108/assets/sticky-scroll.js.map?v=31610194368136171281789968107
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.