PageSourceSearch

https://www.gorillasports.fr/cdn/shop/t/3/assets/dh-slider.js?v=67661005859676893331788361680

js gorillasports.fr collected 2026-10-05 07:57:58 UTC 12,198 bytes, 2 lines download raw bytes

1class DHSlider extends HTMLElement{#track=null;#scrollbar=null;#scrollbarThumb=null;#prevBtn=null;#nextBtn=null;#dots=null;#isDragging=!1;#startPos=0;#startScroll=0;#vertical=!1;#captureScroll=!1;#resizeObserver=null;#mutationObserver=null;#autoplayTimer=null;#autoplayPaused=!1;#captureScrolling=!1;#touchStartPos=0;#verticalTouchLocked=!1;#handlers={};connectedCallback(){this.#init()||(this.#mutationObserver=new MutationObserver(()=>{this.#init()&&(this.#mutationObserver.disconnect(),this.#mutationObserver=null)}),this.#mutationObserver.observe(this,{childList:!0,subtree:!0}))}disconnectedCallback(){this.#stopAutoplay(),this.#unbindEvents(),this.#resizeObserver&&(this.#resizeObserver.disconnect(),this.#resizeObserver=null),this.#mutationObserver&&(this.#mutationObserver.disconnect(),this.#mutationObserver=null)}#init(){return this.#track=this.querySelector("[data-slider-track]"),this.#track?(this.#prevBtn=this.querySelector("[data-slider-prev]"),this.#nextBtn=this.querySelector("[data-slider-next]"),this.#scrollbar=this.querySelector("[data-slider-scrollbar]"),this.#scrollbarThumb=this.querySelector("[data-slider-scrollbar-thumb]"),this.#dots=this.querySelector("[data-slider-dots]"),this.#vertical=this.getAttribute("direction")==="vertical",this.#captureScroll=this.hasAttribute("capture-scroll"),this.#buildDots(),this.#bindEvents(),this.#updateScrollbar(),this.#updateButtons(),this.#startAutoplay(),!0):!1}get loop(){return this.getAttribute("loop")==="true"}get#scrollPos(){return this.#vertical?this.#track.scrollTop:this.#track.scrollLeft}get#scrollSize(){return this.#vertical?this.#track.scrollHeight:this.#track.scrollWidth}get#clientSize(){return this.#vertical?this.#track.clientHeight:this.#track.clientWidth}get#maxScroll(){return this.#scrollSize-this.#clientSize}get#dotCount(){const step=this.#getScrollStep();return step<=0||this.#maxScroll<=0?1:Math.ceil(this.#maxScroll/step-.001)+1}get#currentDotIndex(){const step=this.#getScrollStep();if(step<=0)return 0;const index=Math.round(this.#scrollPos/step);return Math.min(index,this.#dotCount-1)}#updateScrollbar(){if(!this.#scrollbar||!this.#scrollbarThumb)return;if(this.#scrollSize<=this.#clientSize){this.#scrollbar.hidden=!0;return}this.#scrollbar.hidden=!1;const barSize=this.#vertical?this.#scrollbar.clientHeight:this.#scrollbar.clientWidth,thumbSize=Math.max(this.#clientSize/this.#scrollSize*barSize,40),maxThumbPos=barSize-thumbSize,thumbPos=this.#scrollPos/this.#maxScroll*maxThumbPos,sizeProp=this.#vertical?"height":"width",otherProp=this.#vertical?"width":"height",translate=this.#vertical?`translateY(${thumbPos}px)`:`translateX(${thumbPos}px)`;this.#scrollbarThumb.style[sizeProp]=`${thumbSize}px`,this.#scrollbarThumb.style[otherProp]="",this.#scrollbarThumb.style.transform=translate}#getScrollStep(){const slides=Array.from(this.#track.children);if(slides.length===0)return this.#clientSize;const first=slides[0],style=getComputedStyle(this.#track),gap=parseFloat(style.columnGap)||parseFloat(style.rowGap)||parseFloat(style.gap)||0;return(this.#vertical?first.offsetHeight:first.offsetWidth)+gap}scrollPrev(){const step=this.#getScrollStep(),prop=this.#vertical?"top":"left";this.#scrollPos<=0&&this.loop?this.#track.scrollTo({[prop]:this.#maxScroll,behavior:"smooth"}):this.#track.scrollBy({[prop]:-step,behavior:"smooth"})}scrollNext(){const step=this.#getScrollStep(),prop=this.#vertical?"top":"left";this.#scrollPos>=this.#maxScroll-1&&this.loop?this.#track.scrollTo({[prop]:0,behavior:"smooth"}):this.#track.scrollBy({[prop]:step,behavior:"smooth"})}#updateButtons(){if(!this.#prevBtn&&!this.#nextBtn)return;const isScrollable=this.#scrollSize>this.#clientSize;this.#prevBtn&&(isScrollable?(this.#prevBtn.hidden=!1,this.#prevBtn.disabled=!this.loop&&this.#scrollPos<=0):this.#prevBtn.hidden=!0),this.#nextBtn&&(isScrollable?(this.#nextBtn.hidden=!1,this.#nextBtn.disabled=!this.loop&&this.#scrollPos>=this.#maxScroll-1):this.#nextBtn.hidden=!0)}#buildDots(){if(!this.#dots)return;const count=this.#dotCount;if(this.#dots.innerHTML="",count<=1)return;const active=this.#currentDotIndex;for(let i=0;i<count;i++){const btn=document.createElement("button");btn.type="button",btn.setAttribute("aria-label",`Go to position ${i+1}`),i===active&&btn.classList.add("active"),btn.addEventListener("click",()=>this.#scrollToDot(i)),this.#dots.appendChild(btn)}}#updateDots(){if(!this.#dots)return;const buttons=this.#dots.querySelectorAll("button"),expected=this.#dotCount<=1?0:this.#dotCount;if(buttons.length!==expected){this.#buildDots();return}if(buttons.length===0)return;const index=this.#currentDotIndex;buttons.forEach((btn,i)=>btn.classList.toggle("active",i===index))}#scrollToDot(index){const prop=this.#vertical?"top":"left",pos=Math.min(index*this.#getScrollStep(),this.#maxScroll);this.#track.scrollTo({[prop]:pos,behavior:"smooth"})}get#autoplayInterval(){const val=parseFloat(this.getAttribute("autoplay"));return val>0?val*1e3:0}#startAutoplay(){this.#stopAutoplay();const interval=this.#autoplayInterval;interval&&(this.#autoplayTimer=setInterval(()=>{if(!this.#autoplayPaused)if(this.#scrollPos>=this.#maxScroll-1){const prop=this.#vertical?"top":"left";this.#track.scrollTo({[prop]:0,behavior:"smooth"})}else this.scrollNext()},interval))}#stopAutoplay(){this.#autoplayTimer&&(clearInterval(this.#autoplayTimer),this.#autoplayTimer=null)}#pauseAutoplay(){this.#autoplayPaused=!0}#resumeAutoplay(){this.#autoplayPaused=!1}#bindEvents(){const h=this.#handlers;if(h.onScroll=()=>{this.#updateScrollbar(),this.#updateButtons(),this.#updateDots()},this.#track.addEventListener("scroll",h.onScroll,{passive:!0}),this.#vertical&&(h.onWheel=()=>{this.#track.style.overflowY!=="hidden"&&(this.#track.style.overflowY="hidden",this.#track.style.overscrollBehaviorY="inherit")},this.#track.addEventListener("wheel",h.onWheel,{passive:!0}),h.onTouchStart=e=>{this.#track.children.length<=1?(this.#track.style.overflowY="hidden",this.#track.style.overscrollBehaviorY="auto"):this.#track.style.overflowY!=="auto"&&(this.#track.style.overflowY="auto",this.#track.style.overscrollBehaviorY="none"),this.#touchStartPos=e.touches[0].clientY,this.#verticalTouchLocked=!1;const top=this.#track.scrollTop,max=this.#track.scrollHeight-this.#track.clientHeight;top<=0?this.#verticalTouchLocked="top":top>=max-1&&(this.#verticalTouchLocked="bottom")},h.onTouchEnd=e=>{if(!this.#verticalTouchLocked)return;const edge=this.#verticalTouchLocked;this.#verticalTouchLocked=!1;const delta=e.changedTouches[0].clientY-this.#touchStartPos,target=this.getAttribute("edge-scroll-target")||"main",el=document.querySelector(target);el&&(edge==="top"&&delta>30?window.scrollTo({top:0,behavior:"smooth"}):edge==="bottom"&&delta<-30&&el.scrollIntoView({behavior:"smooth"}))},this.#track.addEventListener("touchstart",h.onTouchStart,{passive:!0}),this.#track.addEventListener("touchend",h.onTouchEnd,{passive:!0})),this.#autoplayInterval&&(h.onMouseEnter=()=>this.#pauseAutoplay(),h.onMouseLeave=()=>this.#resumeAutoplay(),this.addEventListener("mouseenter",h.onMouseEnter),this.addEventListener("mouseleave",h.onMouseLeave)),this.#prevBtn&&(h.onPrev=()=>this.scrollPrev(),this.#prevBtn.addEventListener("click",h.onPrev)),this.#nextBtn&&(h.onNext=()=>this.scrollNext(),this.#nextBtn.addEventListener("click",h.onNext)),h.onKeydown=e=>this.#onKeydown(e),this.addEventListener("keydown",h.onKeydown),this.#captureScroll){let fired=!1,gestureTimer=null,directionSign=0,peakDelta=0,prevDelta=0;const GESTURE_TIMEOUT=150;h.onCaptureWheel=e=>{const atStart=this.#scrollPos<=0,atEnd=this.#scrollPos>=this.#maxScroll-1,atEdge=e.deltaY>0&&atEnd||e.deltaY<0&&atStart,sign=Math.sign(e.deltaY),absDelta=Math.abs(e.deltaY);
1if(clearTimeout(gestureTimer),gestureTimer=setTimeout(()=>{fired=!1,directionSign=0,peakDelta=0,prevDelta=0},GESTURE_TIMEOUT),sign!==0&&sign!==directionSign?(fired=!1,peakDelta=0,prevDelta=0):prevDelta<peakDelta*.3&&absDelta>prevDelta*2&&absDelta>10&&(fired=!1,peakDelta=0),absDelta>peakDelta&&(peakDelta=absDelta),prevDelta=absDelta,directionSign=sign,atEdge){fired&&e.preventDefault();return}e.preventDefault(),!fired&&(fired=!0,e.deltaY>0?this.scrollNext():e.deltaY<0&&this.scrollPrev())},this.addEventListener("wheel",h.onCaptureWheel,{passive:!1})}this.#scrollbarThumb&&(h.onDragStart=e=>this.#onDragStart(e),h.onDragMove=e=>this.#onDragMove(e),h.onDragEnd=()=>this.#onDragEnd(),h.onScrollbarClick=e=>this.#onScrollbarClick(e),this.#scrollbarThumb.addEventListener("mousedown",h.onDragStart),this.#scrollbarThumb.addEventListener("touchstart",h.onDragStart,{passive:!1}),this.#scrollbar.addEventListener("click",h.onScrollbarClick)),this.#resizeObserver=new ResizeObserver(()=>{this.#updateScrollbar(),this.#updateButtons(),this.#updateDots()}),this.#resizeObserver.observe(this.#track)}#unbindEvents(){const h=this.#handlers;this.#track&&h.onScroll&&this.#track.removeEventListener("scroll",h.onScroll),this.#prevBtn&&h.onPrev&&this.#prevBtn.removeEventListener("click",h.onPrev),this.#nextBtn&&h.onNext&&this.#nextBtn.removeEventListener("click",h.onNext),h.onKeydown&&this.removeEventListener("keydown",h.onKeydown),this.#track&&h.onWheel&&this.#track.removeEventListener("wheel",h.onWheel),this.#track&&h.onTouchStart&&(this.#track.removeEventListener("touchstart",h.onTouchStart),this.#track.removeEventListener("touchend",h.onTouchEnd)),h.onCaptureWheel&&this.removeEventListener("wheel",h.onCaptureWheel),this.#scrollbarThumb&&h.onDragStart&&(this.#scrollbarThumb.removeEventListener("mousedown",h.onDragStart),this.#scrollbarThumb.removeEventListener("touchstart",h.onDragStart)),this.#scrollbar&&h.onScrollbarClick&&this.#scrollbar.removeEventListener("click",h.onScrollbarClick),this.#stopAutoplay(),this.#removeDragListeners(),this.#handlers={}}#addDragListeners(){const h=this.#handlers;document.addEventListener("mousemove",h.onDragMove),document.addEventListener("mouseup",h.onDragEnd),document.addEventListener("touchmove",h.onDragMove,{passive:!1}),document.addEventListener("touchend",h.onDragEnd)}#removeDragListeners(){const h=this.#handlers;h.onDragMove&&(document.removeEventListener("mousemove",h.onDragMove),document.removeEventListener("touchmove",h.onDragMove)),h.onDragEnd&&(document.removeEventListener("mouseup",h.onDragEnd),document.removeEventListener("touchend",h.onDragEnd))}#onDragStart(e){this.#isDragging=!0,this.#scrollbarThumb.setAttribute("data-dragging","");const pos=e.touches?e.touches[0]:e;this.#startPos=this.#vertical?pos.clientY:pos.clientX,this.#startScroll=this.#scrollPos,e.preventDefault(),this.#addDragListeners()}#onDragMove(e){if(!this.#isDragging)return;const pos=e.touches?e.touches[0]:e,delta=(this.#vertical?pos.clientY:pos.clientX)-this.#startPos,barSize=this.#vertical?this.#scrollbar.clientHeight:this.#scrollbar.clientWidth,thumbSize=this.#vertical?this.#scrollbarThumb.clientHeight:this.#scrollbarThumb.clientWidth,maxThumbPos=barSize-thumbSize,scrollRatio=this.#maxScroll/maxThumbPos;this.#vertical?this.#track.scrollTop=this.#startScroll+delta*scrollRatio:this.#track.scrollLeft=this.#startScroll+delta*scrollRatio,e.preventDefault()}#onDragEnd(){this.#isDragging&&(this.#isDragging=!1,this.#scrollbarThumb.removeAttribute("data-dragging"),this.#removeDragListeners())}#onScrollbarClick(e){if(e.target===this.#scrollbarThumb)return;const scrollbarRect=this.#scrollbar.getBoundingClientRect(),clickPos=this.#vertical?e.clientY-scrollbarRect.top:e.clientX-scrollbarRect.left,barSize=this.#vertical?this.#scrollbar.clientHeight:this.#scrollbar.clientWidth,thumbSize=this.#vertical?this.#scrollbarThumb.clientHeight:this.#scrollbarThumb.clientWidth,targetScroll=(clickPos-thumbSize/2)/(barSize-thumbSize)*this.#maxScroll,prop=this.#vertical?"top":"left";this.#track.scrollTo({[prop]:Math.max(0,Math.min(targetScroll,this.#maxScroll)),behavior:"smooth"})}#onKeydown(e){const prevKeys=this.#vertical?["ArrowUp"]:["ArrowLeft"],nextKeys=this.#vertical?["ArrowDown"]:["ArrowRight"];
1prevKeys.includes(e.key)?(e.preventDefault(),this.scrollPrev()):nextKeys.includes(e.key)&&(e.preventDefault(),this.scrollNext())}}customElements.define("dh-slider",DHSlider);
2//# sourceMappingURL=/cdn/shop/t/3/assets/dh-slider.js.map?v=67661005859676893331788361680

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.