PageSourceSearch

https://trolex.com/wp-content/cache/min/1/wp-content/themes/trolex…/feature-content-slide-js.js?ver=1782815171

js trolex.com collected 2026-10-04 18:43:37 UTC 3,345 bytes, 17 lines download raw bytes

1document.addEventListener("DOMContentLoaded",function(){var carousels=document.querySelectorAll(".js-feature-content-carousel");if(!carousels.length){return}
2function getCardsPerView(){if(window.matchMedia("(max-width: 760px)").matches){return 1}
3if(window.matchMedia("(max-width: 900px)").matches){return 2}
4return 3}
5carousels.forEach(function(carousel){var viewport=carousel.querySelector(".feature-content-slide__viewport");var track=carousel.querySelector(".feature-content-slide__track");var cards=Array.prototype.slice.call(carousel.querySelectorAll(".feature-content-slide__card"));var prevBtn=carousel.querySelector(".feature-content-slide__nav--prev");var nextBtn=carousel.querySelector(".feature-content-slide__nav--next");var dotsWrap=carousel.querySelector(".feature-content-slide__dots");var currentPage=0;var visibleDotCount=4;if(!viewport||!track||!cards.length||!prevBtn||!nextBtn||!dotsWrap){return}
6function getTotalPages(){return Math.max(1,Math.ceil(cards.length/getCardsPerView()))}
7function getVisiblePageCards(){var cardsPerView=getCardsPerView();var startIndex=currentPage*cardsPerView;var endIndex=Math.min(startIndex+cardsPerView,cards.length);return cards.slice(startIndex,endIndex)}
8function updateViewportHeight(){var visibleCards=getVisiblePageCards();var tallest=0;visibleCards.forEach(function(card){tallest=Math.max(tallest,card.offsetHeight)});if(tallest>0){viewport.style.height=tallest+"px"}}
9function getDotWindowStart(){return Math.floor(currentPage/visibleDotCount)*visibleDotCount}
10function renderDots(){var totalPages=getTotalPages();var start=getDotWindowStart();var end=Math.min(start+visibleDotCount,totalPages);dotsWrap.innerHTML="";for(var i=start;i<end;i+=1){var dot=document.createElement("button");dot.type="button";dot.className="feature-content-slide__dot"+(i===currentPage?" is-active":"");dot.setAttribute("aria-label","Go to page "+(i+1));(function(pageIndex){dot.addEventListener("click",function(){goToPage(pageIndex)})})(i);dotsWrap.appendChild(dot)}}
11function updateControls(){var totalPages=getTotalPages();var isStatic=cards.length<=getCardsPerView();prevBtn.disabled=isStatic||currentPage<=0;nextBtn.disabled=isStatic||currentPage>=totalPages-1;carousel.classList.toggle("feature-content-slide__carousel--static",isStatic)}
12function updatePosition(){var cardsPerView=getCardsPerView();var startIndex=currentPage*cardsPerView;var targetCard=cards[startIndex];if(!targetCard){currentPage=0;targetCard=cards[0]}
13track.style.transform="translateX(-"+targetCard.offsetLeft+"px)";window.requestAnimationFrame(function(){updateViewportHeight();renderDots();updateControls()})}
14function goToPage(page){var totalPages=getTotalPages();currentPage=Math.max(0,Math.min(page,totalPages-1));updatePosition()}
15prevBtn.addEventListener("click",function(){goToPage(currentPage-1)});nextBtn.addEventListener("click",function(){goToPage(currentPage+1)});window.addEventListener("resize",function(){var totalPages=getTotalPages();if(currentPage>totalPages-1){currentPage=totalPages-1}
16updatePosition()});window.addEventListener("load",function(){updatePosition()});cards.forEach(function(card){var images=card.querySelectorAll("img");Array.prototype.forEach.call(images,function(image){if(image.complete){return}
17image.addEventListener("load",function(){updateViewportHeight()})})});updatePosition()})})

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.