PageSourceSearch

https://torp.se/dist/client/assets/image-carousel.component-DvNpad74.js

js torp.se collected 2026-09-26 14:23:40 UTC 2,586 bytes, 1 lines download raw bytes

1function l(c,t){if(typeof window.onscrollend<"u")c.addEventListener("scrollend",()=>t(),{passive:!0});else{let e;c.addEventListener("scroll",()=>{e&&(clearTimeout(e),e=null),e=setTimeout(()=>{t()},100)},{passive:!0})}}class a extends HTMLDivElement{constructor(){super(...arguments),this.indicators=null}connectedCallback(){if(!this.initSelectors()){console.error("Carousel block is missing items or action buttons.");return}l(this.items,()=>this.onScrollEnd());for(const t of this.querySelectorAll("button[data-carousel-go]"))t.addEventListener("click",()=>this.onIndicatorClick(t))}initSelectors(){const t=this.querySelector("[data-carousel-items]"),s=this.querySelector('button[data-carousel-go="previous"]'),e=this.querySelector('button[data-carousel-go="next"]');if(!t||!s||!e)return!1;const i=this.querySelector("[data-carousel-indicators]");return this.items=t,this.prevBtn=s,this.nextBtn=e,this.indicators=i,this.createIndicators(),!0}createIndicators(){const t=this.indicators?.querySelector("template");if(!t)return;const e=Array.from(this.items.children).map((i,r)=>{const n=t.cloneNode(!0),o=n.querySelector("button");return r===0&&o.setAttribute("aria-current","true"),o.dataset.carouselGo=r.toString(),o.title=`${o.title} ${r+1}`,n.firstElementChild});this.indicators.innerHTML="",this.indicators?.append(...e)}onScrollEnd(){this.syncArrowStates(),this.syncSlideIndicator()}syncSlideIndicator(){const t=Array.from(this.items.children),s=t.reduce((i,r)=>{const n=Math.abs(i.offsetLeft-this.items.scrollLeft),o=Math.abs(r.offsetLeft-this.items.scrollLeft);return n<o?i:r}),e=t.indexOf(s);this.indicators&&(this.indicators.querySelector("[aria-current]")?.removeAttribute("aria-current"),this.indicators.children.item(e)?.querySelector("button")?.setAttribute("aria-current","true"))}syncArrowStates(){const t=this.items.scrollLeft,s=this.items.scrollWidth-t-this.items.offsetWidth;t===0?(this.prevBtn.setAttribute("disabled",""),this.nextBtn.removeAttribute("disabled")):s===0?(this.nextBtn.setAttribute("disabled",""),this.prevBtn.removeAttribute("disabled")):t>0&&s>0&&(this.nextBtn.removeAttribute("disabled"),this.prevBtn.removeAttribute("disabled"))}onIndicatorClick(t){const s=t.getAttribute("data-carousel-go"),e=Number(s);if(Number.isNaN(e)){const i=this.items.offsetWidth;let r=0;s==="next"?r=i:s==="previous"&&(r=-i),this.items.scrollBy({left:r,behavior:"smooth"})}else{const i=this.items.children.item(e);this.items.scrollTo({left:i.offsetLeft,behavior:"smooth"})}}}customElements.get("image-carousel")||customElements.define("image-carousel",a,{extends:"div"});

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.