PageSourceSearch

https://www.cultbeauty.co.uk/ssr-assets/Carousel.astro_astro_type_script_index_0_lang.B0TB-Lxg.js

js cultbeauty.co.uk collected 2026-10-02 04:04:37 UTC 4,628 bytes, 1 lines download raw bytes

1class l extends HTMLElement{constructor(){super(),this.scopedItems=[],this.isInitialized=!1,this.handlePrevButtonClick=t=>this.scrollItems(t,"prev"),this.handleNextButtonClick=t=>this.scrollItems(t,"next"),this.handlePlayButtonClick=t=>this.updatePlayButton(t),this.handlePauseButtonClick=()=>this.updatePauseButton(),this.handleWrapperScroll=()=>this.updateIntersectionObserver()}connectedCallback(){this.isInitialized||(this.initializeElements(),this.createPips(),this.setupIntersectionObserver(),this.addEventListeners(),this.isInitialized=!0)}initializeElements(){this.scopedItems=[...this.querySelectorAll(".carousel-item:not([hidden])")],this.wrapper=this.querySelector(".carousel"),this.prevButton=this.querySelector(".carousel-prev"),this.nextButton=this.querySelector(".carousel-next"),this.pipsContainer=this.querySelector(".carousel-pips"),this.pauseButton=this.querySelector(".carousel-pause"),this.playButton=this.querySelector(".carousel-play"),this.liveRegion=this.querySelector(".live-region");const t=window.matchMedia("(prefers-reduced-motion: reduce)");this.dataset?.auto==="true"&&!t.matches?this.startAutoScroll(null):this.pauseButton?.classList.add("hidden")}startAutoScroll(t){if(this.interval===void 0){const e=this.dataset?.duration?parseInt(this.dataset.duration):1e4;this.interval=setInterval(()=>this.scrollItems(t,"next"),e)}}stopAutoScroll(){this.interval!==void 0&&(clearInterval(this.interval),this.interval=void 0)}createPips(){this.pipsContainer.innerHTML="";const t=document.createDocumentFragment();for(let e=0;e<this.scopedItems.length;e++){const s=document.createElement("div");s.classList.add("carousel-pip","w-2","h-2","bg-gray-300","rounded-full","mx-1"),t.appendChild(s)}this.pipsContainer.appendChild(t)}setupIntersectionObserver(){this.intersectionObserver=new IntersectionObserver(t=>{const e=t.filter(s=>s.isIntersecting).map(s=>s.target);this.updateActivePips(e),this.toggleControlsVisibility(e)},{root:this.wrapper,threshold:.8}),this.scopedItems.forEach(t=>this.intersectionObserver.observe(t))}addEventListeners(){this.prevButton.addEventListener("click",this.handlePrevButtonClick),this.nextButton.addEventListener("click",this.handleNextButtonClick);const t=window.matchMedia("(prefers-reduced-motion: reduce)");this.dataset.auto==="true"&&!t.matches&&(this.playButton.addEventListener("click",this.handlePlayButtonClick),this.pauseButton.addEventListener("click",this.handlePauseButtonClick)),this.wrapper.addEventListener("scroll",this.handleWrapperScroll)}announceSliderChange(t){const e=this.querySelectorAll(".carousel-pip");let s=-1;if(e.forEach((r,n)=>{r.classList.contains("active")&&(s=n)}),s===-1)return;let i;t==="prev"?s===0?i=this.scopedItems.length:i=s:s===this.scopedItems.length-1?i=1:i=s+2,i&&(this.liveRegion.textContent=`Showing slide ${i} out of ${this.scopedItems.length}`)}updatePlayButton(t){this.startAutoScroll(t),this.pauseButton?.classList.remove("hidden"),this.playButton?.classList.add("hidden")}updatePauseButton(){this.stopAutoScroll(),this.pauseButton?.classList.add("hidden"),this.playButton?.classList.remove("hidden")}updateActivePips(t){const e=this.querySelectorAll(".carousel-pip"),s=t.map(i=>this.scopedItems.indexOf(i));e.forEach((i,r)=>{const n=s.includes(r);i.classList.toggle("active",n),i.classList.toggle("bg-gray-600",n),i.classList.toggle("bg-gray-300",!n)})}toggleControlsVisibility(t){const e=t.length===this.scopedItems.length;this.pipsContainer.style.display=e?"none":"flex",this.prevButton.style.display=e?"none":"",this.nextButton.style.display=e?"none":""}scrollItems(t,e){if(this.contains(document.activeElement)&&t?.type!=="click")return;const s=this.scopedItems[0].clientWidth,i=this.wrapper.scrollWidth-this.wrapper.clientWidth;e==="prev"?this.wrapper.scrollLeft=this.wrapper.scrollLeft<=0?i:this.wrapper.scrollLeft-s:this.wrapper.scrollLeft=this.wrapper.scrollLeft>=i-1?0:this.wrapper.scrollLeft+s,this.announceSliderChange(e)}updateIntersectionObserver(){this.intersectionObserver.disconnect(),this.scopedItems.forEach(t=>this.intersectionObserver.observe(t))}disconnectedCallback(){this.stopAutoScroll(),this.intersectionObserver?.disconnect(),this.prevButton?.removeEventListener("click",this.handlePrevButtonClick),this.nextButton?.removeEventListener("click",this.handleNextButtonClick),this.playButton?.removeEventListener("click",this.handlePlayButtonClick),this.pauseButton?.removeEventListener("click",this.handlePauseButtonClick),this.wrapper?.removeEventListener("scroll",this.handleWrapperScroll),this.isInitialized=!1}}customElements.get("carousel-wrapper")||customElements.define("carousel-wrapper",l);

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.