I think there is a bug with the carousel plugin (Although it could be that I have misconfigured it). Using allowWrap: false disables the prev and next navigation. However, setting 'allowWrap: true' creates 3 times as many slides as there are, which makes the getSlideIndex method return the wrong index.
Steps to reproduce.
Clone an existing Slideshow with
$('.slideshow).clone().
// Init Cycle2.
if ($this.hasClass('clone')) {
$(behavior.carouselSelector).cycle({
slides: behavior.slideSelector,
pauseOnHover: false,
fit: 1,
log: false,
reverse: 0,
width: '100%',
speed: 1000,
timeout: 4000,
swipe: 'true',
autoHeight: 'calc',
});
} else {
var numSlides = parseInt(behavior.slideSelector.size());
$(behavior.carouselSelector).cycle({
slides: behavior.slideSelector,
pauseOnHover: false,
log: true,
speed: 1000,
timeout: 4000,
swipe: 'true',
prev: '> .cycle-prev',
next: '> .cycle-next',
carouselVisible: numSlides, // Calculated depending on how many images there are.
fx: 'carousel',
carouselFluid: true,
});
}
// When previous or next is clicked, advance the other slideshow
var slideshows = $('.field--name-field-gallery-image').on('cycle-next cycle-prev', function(e, opts) {
// advance the other slideshow
slideshows.not(this).cycle('goto', opts.currSlide);
});
// On click of a slide get the index.
// Move both slides to that index
$('.navigator .cycle-slide').click(function(){
var index = $('.navigator').data('cycle.API').getSlideIndex(this);
slideshows.cycle('goto', index);
});
I think there is a bug with the carousel plugin (Although it could be that I have misconfigured it). Using
allowWrap: false
disables the prev and next navigation. However, setting 'allowWrap: true' creates 3 times as many slides as there are, which makes the getSlideIndex method return the wrong index.Steps to reproduce.
$('.slideshow).clone()
.Version I'm using:
jQuery 1.9 Cycle2 '2.1.6'; Carousel Plugin: v20141007