var swiperBox = []; var swiperIdx = 0; (function($){ $(document).ready( function() { _initCarousel(); }); function _update(calNo){ var updateNo = -1; if(calNo){ updateNo = calNo; } if(swiperBox.length > 0){ $(swiperBox).each(function(i){ if(updateNo == -1 || updateNo == i){ swiperBox[i].update(); } }); } } function _initCarousel(){ $('.ems_carousel:not(.set)').each(function(){ var sliderFlg = $(this).attr('cal-slider'); if(sliderFlg == 1){ var _direction = 'horizontal'; if($(this).attr('cal-direction')){ _direction = $(this).attr('cal-direction'); } var _loop = false; var _autoPlay = false; if($(this).attr('cal-loop')){ _loop = $(this).attr('cal-loop'); _autoPlay = {delay:$(this).attr('cal-anime-speed'), disableOnInteraction: false}; } var swiper = new Swiper( this , { loop : _loop, freeMode: true, direction: _direction, slidesPerView: 'auto', autoplay: _autoPlay, speed: 500, navigation: {nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev'}, }); swiperBox.push(swiper); $(this).attr('cal-no' , swiperIdx++); } // 表示(初動ちらつき対策) $(this).closest('.related_item_list').css('visibility', 'visible'); // セット完了クラス $(this).addClass('set'); }); $('.today_carousel:not(.set)').each(function(){ var sliderFlg = $(this).attr('cal-slider'); var todayPerView = 1.2; if($(this).attr('slider-per-view')){ todayPerView = $(this).attr('slider-per-view'); } var todaySpaceBetween = 8; if($(this).attr('slider-space-between')){ todaySpaceBetween = $(this).attr('slider-space-between'); } var todayCenteredSlides = true; if($(this).attr('slider-centered-slides')){ todayCenteredSlides = $(this).attr('slider-centered-slides'); } var todayAutoHeight = true; if($(this).attr('slider-auto-height')){ todayAutoHeight = $(this).attr('slider-auto-height'); } var todayGrabCursor = true; if($(this).attr('slider-grab-cursor')){ todayGrabCursor = $(this).attr('slider-grab-cursor'); } var todayWatchSlidesProgress = true; if($(this).attr('slider-watch-slides-progress')){ todayWatchSlidesProgress = $(this).attr('slider-watch-slides-progress'); } if(sliderFlg == 1){ var _direction = 'horizontal'; var dataSqn = $(this).find('.today').attr('data-sqn'); var swiper = new Swiper( this , { slidesPerView: todayPerView, spaceBetween: todaySpaceBetween, initialSlide: dataSqn, centeredSlides: todayCenteredSlides, autoHeight: todayAutoHeight, grabCursor: todayGrabCursor, watchSlidesProgress: todayWatchSlidesProgress, breakpoints: { 1024: { slidesPerView: 1.6, spaceBetween: 16, } } }); swiperBox.push(swiper); $(this).attr('cal-no' , swiperIdx++); } // 表示(初動ちらつき対策) $(this).closest('.related_item_list').css('visibility', 'visible'); // セット完了クラス $(this).addClass('set'); }); } this.updateCarousel = _update; this.initCarousel = _initCarousel; }(jQuery));