$(function(){ var viewswiper = new swiper(".k_ys_history_year_1 #k_ys_history_content",{ onslidechangestart: function() { updatenavposition() } }); var previewswiper = new swiper(".k_ys_history_year_1 #k_ys_history_year",{ slidesperview: 6, allowtouchmove: false, spacebetween: 0, breakpoints: { 768: { slidesperview: 4, spacebetween: 0 }, 620: { slidesperview: 3, spacebetween: 0 }, 620: { slidesperview: 3, spacebetween: 0 }, 460: { slidesperview: 2, spacebetween: 0 }, }, ontap: function() { viewswiper.slideto(previewswiper.clickedindex) } }); $('.k_ys_history_year_1 .view .arrow-left,.k_ys_history_year_1 .k_ys_history_sbt_left').on('click', function(e) { e.preventdefault() if (viewswiper.activeindex == 0) { viewswiper.slideto(viewswiper.slides.length - 1, 1000); return } viewswiper.slideprev(); }); $('.k_ys_history_year_1 .view .arrow-right,.k_ys_history_year_1 .k_ys_history_sbt_right').on('click', function(e) { e.preventdefault() if (viewswiper.activeindex == viewswiper.slides.length - 1) { viewswiper.slideto(0, 1000); return } viewswiper.slidenext(); }); function updatenavposition() { $('.k_ys_history_year_1 #k_ys_history_year .active-nav').removeclass('active-nav') var activenav = $('.k_ys_history_year_1 #k_ys_history_year .swiper-slide').eq(viewswiper.activeindex).addclass('active-nav') if (!activenav.hasclass('swiper-slide-visible')) { if (activenav.index() > previewswiper.activeindex) { var thumbspernav = math.floor(previewswiper.width / activenav.width()) - 1 previewswiper.slideto(activenav.index() - thumbspernav) } else { previewswiper.slideto(activenav.index()) } } } });