if (activeNav.index() > previewSwiper.activeIndex) { var thumbsPerNav = Math.floor(previewSwiper.width / activeNav.width()) - 1; previewSwiper.slideTo(activeNav.index() - thumbsPerNav); } else { previewSwiper.slideTo(activeNav.index()); } } }