Open ghost opened 9 years ago
The remove command updates the currSlide but not the nextSlide. As a result a slide will be skipped in the slideshow. This snippet fixes the bug:
currSlide
nextSlide
remove: function( index ) { var opts = this.opts(); var slide, slideToRemove, slides = [], slideNum = 1; for ( var i=0; i < opts.slides.length; i++ ) { slide = opts.slides[i]; if ( i == index ) { slideToRemove = slide; } else { slides.push( slide ); $( slide ).data('cycle.opts').slideNum = slideNum; slideNum++; } } if ( slideToRemove ) { opts.slides = $( slides ); opts.slideCount--; $( slideToRemove ).remove(); if (index == opts.currSlide) { opts.currSlide = (opts.currSlide + opts.slideCount - 1) % opts.slideCount; opts.nextSlide = Math.max(opts.nextSlide - 1, 0); opts.API.advanceSlide( 1 ); } else if ( index < opts.currSlide ) { opts.currSlide--; opts.nextSlide = Math.max(opts.nextSlide - 1, 0); } else { opts.nextSlide = opts.nextSlide % opts.slideCount; } opts.API.trigger('cycle-slide-removed', [ opts, index, slideToRemove ]).log('cycle-slide-removed'); opts.API.updateView(); } }
The remove command updates the
currSlide
but not thenextSlide
. As a result a slide will be skipped in the slideshow. This snippet fixes the bug: