Skip to content

Commit

Permalink
Fixed bug: If the carousel does not (yet) contain any items, the swipe
Browse files Browse the repository at this point in the history
event throws an error. Even if you add items later on, the swipe doesn't
work anymore.
  • Loading branch information
jepfp committed Jun 10, 2017
1 parent 7da054c commit 20261b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion jquery.bcSwipe.js
Expand Up @@ -35,6 +35,7 @@
var difference = start - x;
if (Math.abs(difference) >= config.threshold) {
cancelTouch();
if(isCarouselEmpty($(this))) return;
if (difference > 0) {
$(this).carousel('next');
}
Expand All @@ -44,6 +45,10 @@
}
}
}

function isCarouselEmpty(carousel){
return carousel.find(".item.active").length < 1
}

function cancelTouch() {
this.removeEventListener('touchmove', onTouchMove);
Expand All @@ -54,4 +59,4 @@

return this;
};
})(jQuery);
})(jQuery);
2 changes: 1 addition & 1 deletion jquery.bcSwipe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 20261b8

Please sign in to comment.