1let swiperInstance = null; 2 3function initSlider() { 4 // Destroy instance cÅ© nếu có 5 if (swiperInstance) { 6 swiperInstance.destroy(true, true); 7 } 8 9 // Khá»i tạo Swiper má»i 10 swiperInstance = new Swiper('.gwd-slider-swiper', { 11 virtual: false, 12 13 loop: true, 14 centeredSlides: true, 15 loopAdditionalSlides: 8, 16 17 speed: 800, 18 19 autoplay: { 20 delay: 1500, 21 disableOnInteraction: false, 22 }, 23 24 slidesPerView: 4, 25 spaceBetween: 20, 26 27 breakpoints: { 28 0: { slidesPerView: 4 }, 29 768: { slidesPerView: 6 }, 30 1200: { slidesPerView: 8 }, 31 }, 32 33 observer: true, 34 observeParents: true, 35 36 navigation: { 37 nextEl: '.gwd-slider-next', 38 prevEl: '.gwd-slider-prev', 39 }, 40}); 41} 42 43function setCardHeight() { 44 const cards = document.querySelectorAll('.gwd-slider-brand-card'); 45 if (cards.length === 0) return; 46 47 // Reset height trưá»c khi tÃnh toán 48 cards.forEach(card => card.style.height = 'auto'); 49 50 let maxHeight = 0; 51 cards.forEach(card => { 52 const h = card.offsetHeight; 53 if (h > maxHeight) maxHeight = h; 54 }); 55 56 cards.forEach(card => { 57 card.style.height = maxHeight + 'px'; 58 }); 59} 60 61// Khá»i tạo khi DOM ready 62document.addEventListener('DOMContentLoaded', function() { 63 initSlider(); 64}); 65 66// Xá» lý height khi window load (images Äã tải xong) 67window.addEventListener('load', () => { 68 setCardHeight(); 69 // Reload slider sau khi set height 70 setTimeout(() => { 71 if (swiperInstance) { 72 swiperInstance.update(); 73 } 74 }, 100); 75}); 76 77// Optional: Reload khi resize window 78window.addEventListener('resize', () => { 79 clearTimeout(window.resizeTimer); 80 window.resizeTimer = setTimeout(() => { 81 setCardHeight(); 82 if (swiperInstance) { 83 swiperInstance.update(); 84 } 85 }, 250); 86}); 87 88// Function Äá» reload slider từ bên ngoà i nếu cần 89window.reloadSlider = function() { 90 setCardHeight(); 91 initSlider(); 92};
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.