62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
(function($) {
|
|
"use strict";
|
|
|
|
if (typeof window.initRollingBannerFooter === 'function') {
|
|
// return;
|
|
}
|
|
|
|
window.initRollingBannerFooter = function(moduleId) {
|
|
const $module = $('#' + moduleId);
|
|
if (!$module.length) return;
|
|
|
|
const $swiperContainer = $module.find('.swiper-container');
|
|
|
|
const autoplayDelay = parseInt($swiperContainer.data('autoplay-delay'), 10) || 3000;
|
|
const slidesPerViewPC = parseInt($swiperContainer.data('slides-per-view'), 10) || 6;
|
|
const bannerCount = parseInt($swiperContainer.data('banner-count'), 10) || 0;
|
|
|
|
// 💡 [핵심 수정] 배너 개수가 화면에 보여줄 개수보다 많을 때만 loop를 활성화
|
|
const isLoop = bannerCount > slidesPerViewPC;
|
|
|
|
new Swiper($swiperContainer[0], {
|
|
spaceBetween: 20,
|
|
loop: isLoop, // 💡 [수정] 동적으로 loop 설정
|
|
autoplay: {
|
|
delay: autoplayDelay,
|
|
disableOnInteraction: false,
|
|
},
|
|
navigation: {
|
|
nextEl: $module.find('.swiper-button-next')[0],
|
|
prevEl: $module.find('.swiper-button-prev')[0],
|
|
},
|
|
observer: true,
|
|
observeParents: true,
|
|
// 💡 [핵심 수정] 반응형 Breakpoints 설정
|
|
breakpoints: {
|
|
// 320px 이상일 때
|
|
320: {
|
|
slidesPerView: 3,
|
|
spaceBetween: 10
|
|
},
|
|
// 768px 이상일 때 (태블릿)
|
|
768: {
|
|
slidesPerView: 4,
|
|
spaceBetween: 20
|
|
},
|
|
// 1024px 이상일 때 (PC)
|
|
1024: {
|
|
slidesPerView: slidesPerViewPC,
|
|
spaceBetween: 20
|
|
},
|
|
}
|
|
});
|
|
};
|
|
|
|
$(function() {
|
|
$('.rolling-banner-footer').each(function() {
|
|
window.initRollingBannerFooter($(this).attr('id'));
|
|
});
|
|
});
|
|
|
|
})(jQuery);
|