Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions lib/jquery.tinycarousel.js
Original file line number Diff line number Diff line change
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")) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the original intention was to have the person implementing the class to handle the disable CSS class on their own. e.g., Check for disable and remove events if desired. It felt "right" to me to just do this in the plugin.

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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tinycarousel",
"version": "2.1.8",
"version": "2.1.9",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped the version up for this bug fix. Not sure if this is kosher practice. 🙇

"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
Original file line number Diff line number Diff line change
@@ -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