It works for me like this:
three conditions
My Swiper 3.4.2
Slider in tabs (5pcs)
Scroll arrows are inside the slider
// showed initialization as an example, in my case, to initialize each of the 5 sliders, such code in each tab.
var swiper = new Swiper('#tab-<?php echo $count; ?> .swiper-container', {
mode: 'horizontal',
slidesPerView: 4,
spaceBetween: 30,
nextButton: '#five_modules_tabs #tab-<?php echo $count; ?> .swiper-button-next',
prevButton: '#five_modules_tabs #tab-<?php echo $count; ?> .swiper-button-prev',
breakpoints: {
// when window width is <= 410px
410: {
slidesPerView: 1.1,
spaceBetween: 4
},
// when window width is <= 430px
430: {
slidesPerView: 1.11,
spaceBetween: 4
},
// when window width is <= 460px
460: {
slidesPerView: 1.12,
spaceBetween: 4,
nextButton: '',
prevButton: '',
},
// when window width is <= 640px
640: {
slidesPerView: 2,
spaceBetween: 4
},
// when window width is <= 767px
767: {
slidesPerView: 3,
spaceBetween: 4
},
// when window width is <= 991px
991: {
slidesPerView: 3,
spaceBetween: 12
},
// when window width is <= 1199px
1199: {
slidesPerView: 3,
spaceBetween: 15
}
},
pagination: '#five_modules_tabs #tab-<?php echo $count; ?> .swiper-pagination',
paginationClickable: true,
autoplay: 1000,
autoplayDisableOnInteraction: false, // Does not work
//loop: true, //this hinder autoplay
observer: true,
observeParents: true,
observeSlideChildren: true
});
But for this code .on("click")
to work without errors, you need to exclude loop: true
// restart autoplay after switching tabs
$("#five_modules_tabs .nav-tabs li").on("click", function(e) {
var gallerySwiper = $('#five_modules_tabs .swiper-container');
$.each(gallerySwiper, function( index, value ) {
value.swiper.stopAutoplay();
value.swiper.startAutoplay();
});
});
loop: true,
- This hinder autoplay
Instead of a non-working autoplayDisableOnInteraction: true,
stops the slider on hover.
You need to stop when hovering on any of these blocks (.swiper-container, .swiper-button-prev, .swiper-button-next, .swiper-pagination
) === ('#five_modules_tabs .swiper-container')
All blocks are inside .swiper-viewport
$('#five_modules_tabs .swiper-container').each(function(index, value) {
$('#five_modules_tabs .swiper-viewport').hover(function() {
value.swiper.stopAutoplay();
}, function() {
value.swiper.startAutoplay();
});
});
Look at the picture!
autoplayDisableOnInteraction
butdisableOnInteraction
. – Cornhusking