1/* ============================================================================= 2 SWIPER - PRODUCT SHOWCASE (scroll) â BẢN CLONE CHO TRANG /home 3 ----------------------------------------------------------------------------- 4 Clone từ: public/frontend_layout_2025_vibecode/assets/plugin/swiper/showcase-scroll-swiper.js 5 Bản gá»c GIá»® NGUYÃN, /vi vẫn chạy bằng bản gá»c. 6 7 Khác bản gá»c: bản gá»c chụp danh sách phần tá» má»t lần trong DOMContentLoaded nên 8 không thấy section nạp trá» . Bản nà y giữ má»t danh sách phần tá» "Äã nháºn", ÄÆ°á»£c 9 bá»i thêm má»i lần window.homeInitShowcaseScrollSwiper(root) ÄÆ°á»£c gá»i; init/destroy và handler resize 10 vẫn chạy y như cÅ© trên danh sách Äó. 11 ============================================================================= */ 12 13// Showcase Scroll Mode - Swiper Initialization 14(function () { 15 const swiperElements = []; 16 let swipers = []; 17 18 function init() { 19 // Destroy existing 20 swipers.forEach(s => s && s.destroy && s.destroy(true, true)); 21 swipers = []; 22 23 // Only on mobile/tablet/medium desktop (not large desktop) 24 if (window.innerWidth > 1440) return; 25 26 swiperElements.forEach(function(el, index) { 27 try { 28 const swiper = new Swiper(el, { 29 slidesPerView: 'auto', 30 spaceBetween: 16, 31 freeMode: true, 32 grabCursor: true, 33 slidesOffsetBefore: 0, 34 slidesOffsetAfter: 0, 35 }); 36 37 swipers.push(swiper); 38 } catch (e) { 39 // Silently handle errors 40 } 41 }); 42 } 43 44 // Nháºn thêm phần tá» từ HTML vừa chèn rá»i init lại 45 window.homeInitShowcaseScrollSwiper = function (root) { 46 var scope = (root && root.querySelectorAll) ? root : document; 47 var found = scope.querySelectorAll('.product-showcase-scroll .swiper-showcase-products'); 48 var added = false; 49 Array.prototype.forEach.call(found, function (el) { 50 if (swiperElements.indexOf(el) === -1) { swiperElements.push(el); added = true; } 51 }); 52 if (added) init(); 53 }; 54 55 let timer; 56 window.addEventListener('resize', () => { 57 clearTimeout(timer); 58 timer = setTimeout(init, 250); 59 }); 60})();
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.