Skip to content

Commit

Permalink
Merge 57bf592 into beb5a20
Browse files Browse the repository at this point in the history
  • Loading branch information
sprak3000 committed May 6, 2016
2 parents beb5a20 + 57bf592 commit da6ffa8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
29 changes: 24 additions & 5 deletions lib/jquery.tinycarousel.js
Expand Up @@ -128,7 +128,11 @@
self.slideCurrent = self.options.start || 0;
slidesVisible = Math.ceil(viewportSize / slideSize);

$overview.append($slides.slice(0, slidesVisible).clone().addClass("mirrored"));
// If our total slides fill the entire visible space, do not add the mirrored items.
if(0 < self.slidesTotal - slidesVisible) {
$overview.append($slides.slice(0, slidesVisible).clone().addClass("mirrored"));
}

$overview.css(sizeLabel.toLowerCase(), slideSize * (self.slidesTotal + slidesVisible));

_setButtons();
Expand All @@ -143,19 +147,26 @@
function _setEvents() {
if(self.options.buttons) {
$prev.click(function() {
self.move(--slideIndex);
if(!$(this).hasClass("disable")) {
self.move(--slideIndex);
}

return false;
});

$next.click(function() {
self.move(++slideIndex);
if(!$(this).hasClass("disable")) {
self.move(++slideIndex);
}

return false;
});
}

$(window).resize(self.update);
$(window).resize(function() {
self.update();
self.move(self.slideCurrent);
});

if(self.options.bullets) {
$container.on("click", ".bullet", function() {
Expand Down Expand Up @@ -218,6 +229,10 @@
$overview.css(posiLabel, -(self.slidesTotal) * slideSize);
}

if(self.options.infinite && 0 >= self.slidesTotal - slidesVisible) {
self.slideCurrent = slideIndex = 0;
}

if(slideIndex > self.slidesTotal) {
self.slideCurrent = slideIndex = 1;
$overview.css(posiLabel, 0);
Expand All @@ -239,7 +254,6 @@
}
});

_setButtons();
self.start();

return self;
Expand All @@ -255,6 +269,11 @@
$next.toggleClass("disable", self.slideCurrent >= self.slidesTotal - slidesVisible);
}

if(self.options.buttons && self.options.infinite) {
$prev.toggleClass("disable", 0 >= self.slidesTotal - slidesVisible);
$next.toggleClass("disable", 0 >= self.slidesTotal - slidesVisible);
}

if(self.options.bullets) {
$bullets.removeClass("active");
$($bullets[self.slideCurrent]).addClass("active");
Expand Down
6 changes: 3 additions & 3 deletions lib/jquery.tinycarousel.min.js

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

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "tinycarousel",
"version": "2.1.8",
"version": "2.1.9",
"description": "A lightweight cross browser jQuery based infinite carousel",
"homepage": "https://baijs.com/tinycarousel",
"main": "lib/jquery.tinycarousel.js",
Expand Down
2 changes: 1 addition & 1 deletion tinycarousel.jquery.json
@@ -1,7 +1,7 @@
{
"name": "tinycarousel",
"title": "Tiny Carousel",
"version": "2.1.8",
"version": "2.1.9",
"description": "A lightweight responsive infinite carousel.",
"homepage": "http://www.baijs.com/tinycarousel",
"repository": {
Expand Down

0 comments on commit da6ffa8

Please sign in to comment.