1document.addEventListener('DOMContentLoaded', function () { 2 function normalizeSlideHeights() { 3 const slides = document.querySelectorAll('.roomvo-related-products .swiper-slide'); 4 let maxHeight = 0; 5 6 slides.forEach(slide => { 7 slide.style.height = 'auto'; 8 }); 9 10 slides.forEach(slide => { 11 const height = slide.offsetHeight; 12 if (height > maxHeight) maxHeight = height; 13 }); 14 15 slides.forEach(slide => { 16 slide.style.height = `${maxHeight + 2}px`; 17 }); 18 } 19 20 function waitForAllImages(callback) { 21 const images = document.querySelectorAll('.roomvo-related-products .swiper-slide img'); 22 let remaining = images.length; 23 24 if (remaining === 0) { 25 callback(); 26 return; 27 } 28 29 function checkDone() { 30 remaining--; 31 if (remaining === 0) { 32 callback(); 33 } 34 } 35 36 images.forEach(img => { 37 if (img.complete && img.naturalHeight !== 0) { 38 checkDone(); 39 } else { 40 img.addEventListener('load', checkDone, { once: true }); 41 img.addEventListener('error', checkDone, { once: true }); 42 } 43 }); 44 } 45 46 new Swiper('.roomvo-related-products__slider', { 47 freeMode: { 48 enabled: true, 49 sticky: true, 50 }, 51 on: { 52 init: () => { 53 waitForAllImages(() => { 54 normalizeSlideHeights(); 55 }); 56 } 57 }, 58 freeModeMomentumBounce: false, 59 spaceBetween: 16, 60 watchOverflow: true, 61 watchSlidesProgress: false, 62 centeredSlides: false, 63 slideToClickedSlide: true, 64 slidesPerView: 1, 65 navigation: { 66 nextEl: '.related-product-swiper__button-next', 67 prevEl: '.related-product-swiper__button-prev', 68 }, 69 breakpoints: { 70 0: { 71 slidesPerView: 1, 72 }, 73 640: { 74 slidesPerView: 2, 75 }, 76 700: { 77 slidesPerView: 3, 78 }, 79 960: { 80 slidesPerView: 4, 81 }, 82 } 83 }); 84 85 window.addEventListener('resize', () => { 86 waitForAllImages(() => { 87 normalizeSlideHeights(); 88 }); 89 }); 90});
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.