1(function () { 2 const viewport = document.querySelector('.fotogallery__viewport'); 3 const prevBtn = document.querySelector('.fotogallery__carousel__btn-prev'); 4 const nextBtn = document.querySelector('.fotogallery__carousel__btn-next'); 5 const carouselOptions = { 6 draggable: false, 7 align: 'start', 8 slidesToScroll: 1 9 }; 10 11 const embla = EmblaCarousel(viewport, carouselOptions); 12 13 setupPrevNextBtns(prevBtn, nextBtn, embla); 14 embla.on('init', () => { 15 disablePrevNextBtns(prevBtn, nextBtn, embla)(); 16 }); 17 embla.on('select', () => { 18 disablePrevNextBtns(prevBtn, nextBtn, embla)(); 19 }); 20 21 22 /** 23 * Predispone i bottoni (< >) per il Carousel 24 * 25 * @param {*} prevBtn 26 * @param {*} nextBtn 27 * @param {*} embla 28 */ 29 function setupPrevNextBtns(prevBtn, nextBtn, embla) { 30 prevBtn.addEventListener("click", embla.scrollPrev, false); 31 nextBtn.addEventListener("click", embla.scrollNext, false); 32 } 33 34 /** 35 * Disabilita i bottoni (< >) rimuovendo/aggiungento l'attributo 'disabled' 36 * 37 * @param {*} prevBtn 38 * @param {*} nextBtn 39 * @param {*} embla 40 * @returns 41 */ 42 function disablePrevNextBtns(prevBtn, nextBtn, embla) { 43 return () => { 44 if (embla.canScrollPrev()) prevBtn.removeAttribute("disabled"); 45 else prevBtn.setAttribute("disabled", "disabled"); 46 47 if (embla.canScrollNext()) nextBtn.removeAttribute("disabled"); 48 else nextBtn.setAttribute("disabled", "disabled"); 49 }; 50 } 51})();
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.