PageSourceSearch

https://www.youngla.com/cdn/shop/t/205/assets/cart-trending-carousel.js?v=108318264462450364301789109233

js youngla.com collected 2026-09-25 18:53:16 UTC 7,127 bytes, 2 lines download raw bytes

1class CartTrendingCarousel extends HTMLElement{connectedCallback(){this._initialized||(this._initialized=!0,this._onScroll=this._onScroll.bind(this),this._onScrollEnd=this._onScrollEnd.bind(this),this._onResize=this._onResize.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onMouseClick=this._onMouseClick.bind(this),this._onDragStart=this._onDragStart.bind(this),this._onFinePointerChange=this._onFinePointerChange.bind(this),this._onNavClick=this._onNavClick.bind(this),this._isCompensating=!1,this._threshold=0,this._seeded=!1,this._isDragging=!1,this._dragMoved=!1,this._dragPosition=null,this._dragTarget=null,this._awaitingScrollEnd=!1,this._scrollEndTimeout=null,this.addEventListener("scroll",this._onScroll,{passive:!0}),this.addEventListener("dragstart",this._onDragStart),this._resizeObserver=new ResizeObserver(()=>{this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=requestAnimationFrame(this._onResize)}),this._resizeObserver.observe(this),this._finePointerQuery=window.matchMedia("screen and (pointer: fine)"),this._finePointerQuery.addEventListener("change",this._onFinePointerChange),this._syncDragListeners(this._finePointerQuery.matches),this._bindNav(),this._measure(),this._seed(),this._updateEdges())}disconnectedCallback(){this.removeEventListener("scroll",this._onScroll),this.removeEventListener("scrollend",this._onScrollEnd),this.removeEventListener("mousedown",this._onMouseDown),this.removeEventListener("mousemove",this._onMouseMove),this.removeEventListener("click",this._onMouseClick,!0),this.removeEventListener("dragstart",this._onDragStart),document.removeEventListener("mouseup",this._onMouseUp),this._finePointerQuery&&(this._finePointerQuery.removeEventListener("change",this._onFinePointerChange),this._finePointerQuery=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._scrollEndTimeout&&clearTimeout(this._scrollEndTimeout),this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._navButtons&&(this._navButtons.forEach(button=>button.removeEventListener("click",this._onNavClick)),this._navButtons=null),this._nav=null,this.classList.remove("is-dragging"),this._initialized=!1}get slides(){return Array.from(this.children).filter(el=>el.nodeType===1)}get canLoop(){return this.hasAttribute("loop")&&this.slides.length>=4}_onDragStart(event){event.preventDefault()}_onFinePointerChange(event){this._syncDragListeners(event.matches)}_syncDragListeners(enabled){this.removeEventListener("mousedown",this._onMouseDown),enabled?(this.addEventListener("mousedown",this._onMouseDown),this.classList.add("is-draggable")):this.classList.remove("is-draggable")}_bindNav(){const container=this.closest(".cart-trending-products");this._nav=container?container.querySelector("[data-cart-trending-nav]"):null,this._navButtons=this._nav?Array.from(this._nav.querySelectorAll("[data-cart-trending-direction]")):[],this._navButtons.forEach(button=>button.addEventListener("click",this._onNavClick))}_onNavClick(event){const sign=event.currentTarget.getAttribute("data-cart-trending-direction")==="prev"?-1:1;this.scrollBy({left:sign*this._scrollStep(),behavior:"smooth"})}_scrollStep(){return this._slideStep?Math.max(1,Math.floor(this.clientWidth*.9/this._slideStep))*this._slideStep:this.clientWidth}_measure(){const slides=this.slides;if(slides.length===0)return;const slideWidth=slides[0].getBoundingClientRect().width;if(slideWidth<=0){this._slideStep=0;return}const styles=getComputedStyle(this),gap=parseFloat(styles.columnGap||styles.gap)||0;this._slideStep=slideWidth+gap,this._threshold=Math.max(this._slideStep*.75,1)}_onResize(){this._measure(),this._seeded||this._seed(),this._updateEdges()}_updateEdges(){if(!this._nav||this._navButtons.length===0)return;const maxScroll=this.scrollWidth-this.clientWidth,scrollable=maxScroll>1;this._nav.hidden=!scrollable;const loops=this.canLoop;this._navButtons.forEach(button=>{const isPrev=button.getAttribute("data-cart-trending-direction")==="prev";let enabled=!1;scrollable&&(loops?enabled=!0:enabled=isPrev?this.scrollLeft>1:this.scrollLeft<maxScroll-1),button.disabled=!enabled})}_seed(){if(this._seeded||!this.canLoop||!this._slideStep)return;const last=this.lastElementChild;last&&(this._isCompensating=!0,this.insertBefore(last,this.firstElementChild),this.scrollLeft=this._slideStep,this._isCompensating=!1,this._seeded=!0)}_onScroll(){this._updateEdges(),!(this._isDragging||this._isCompensating)&&(this._scrollEndTimeout&&clearTimeout(this._scrollEndTimeout),"onscrollend"in window?this._awaitingScrollEnd||(this._awaitingScrollEnd=!0,this.addEventListener("scrollend",this._onScrollEnd,{once:!0})):this._scrollEndTimeout=setTimeout(this._onScrollEnd,120))}_onScrollEnd(){this._awaitingScrollEnd=!1,this._scrollEndTimeout=null,this.canLoop&&this._balance()}_balance(){if(!this.canLoop||this._isCompensating||this._isDragging||this.slides.length<4||!this._slideStep)return;const maxScroll=this.scrollWidth-this.clientWidth;if(!(maxScroll<=0)){for(;this.scrollLeft>maxScroll-this._threshold;){const first=this.firstElementChild;if(!first)break;this._isCompensating=!0,this.appendChild(first),this.scrollLeft-=this._slideStep,this._isCompensating=!1;const nextMax=this.scrollWidth-this.clientWidth;if(this.scrollLeft<=nextMax-this._threshold)break}for(;this.scrollLeft<this._threshold;){const last=this.lastElementChild;if(!last||(this._isCompensating=!0,this.insertBefore(last,this.firstElementChild),this.scrollLeft+=this._slideStep,this._isCompensating=!1,this.scrollLeft>=this._threshold))break}}}_onMouseDown(event){event.button===0&&(event.target.closest("button, input, label, select, textarea")||(event.preventDefault(),this._isDragging=!0,this._dragMoved=!1,this._dragTarget=event.target,this._dragPosition={left:this.scrollLeft,x:event.clientX},this.classList.add("is-dragging"),this.addEventListener("mousemove",this._onMouseMove),this.addEventListener("click",this._onMouseClick,!0),document.addEventListener("mouseup",this._onMouseUp)))}_onMouseMove(event){if(!this._isDragging||!this._dragPosition)return;const dx=event.clientX-this._dragPosition.x;Math.abs(dx)>3&&(this._dragMoved=!0),event.preventDefault(),this.scrollLeft=this._dragPosition.left-dx,this.canLoop&&this._balance(),this._updateEdges()}_onMouseUp(){if(this._isDragging){if(this._isDragging=!1,this.classList.remove("is-dragging"),this.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),!this._dragMoved){const focusable=this._dragTarget&&this._dragTarget.closest("a[href], button, [tabindex]");focusable&&focusable.focus({preventScroll:!0})}this._dragTarget=null}}_onMouseClick(event){this._dragMoved&&(event.preventDefault(),event.stopPropagation()),this.removeEventListener("click",this._onMouseClick,!0)}}customElements.get("cart-trending-carousel")||customElements.define("cart-trending-carousel",CartTrendingCarousel);
2//# sourceMappingURL=/cdn/shop/t/205/assets/cart-trending-carousel.js.map?v=108318264462450364301
2789109233

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.