From 2876efc34d553df7a99d6ef64d52ba6ca1a15d96 Mon Sep 17 00:00:00 2001 From: Marc Brooks Date: Mon, 21 Oct 2013 23:51:34 -0500 Subject: [PATCH] Recognize wrapping in either direction on a API.next call. In API.next, when scrolling backwards (due to opts.reverse), must recognize wrapping before first the first slide to prevent issues. --- jquery.cycle2.carousel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jquery.cycle2.carousel.js b/jquery.cycle2.carousel.js index aa45d57..e19d0f7 100644 --- a/jquery.cycle2.carousel.js +++ b/jquery.cycle2.carousel.js @@ -15,7 +15,8 @@ $( document ).on('cycle-bootstrap', function( e, opts, API ) { // override default 'next' function API.next = function() { var count = opts.reverse ? -1 : 1; - if ( opts.allowWrap === false && ( opts.currSlide + count ) > opts.slideCount - opts.carouselVisible ) + var newCurrent = opts.currSlide + count; + if ( opts.allowWrap === false && (newCurrent < 0 || newCurrent > opts.slideCount - opts.carouselVisible )) return; opts.API.advanceSlide( count ); opts.API.trigger('cycle-next', [ opts ]).log('cycle-next');