vendor/assets/javascripts/jquery.lory.js in lory-rails-0.1.4 vs vendor/assets/javascripts/jquery.lory.js in lory-rails-0.2.0
- old
+ new
@@ -281,13 +281,21 @@
nextCtrl.classList.remove('disabled');
}
if (typeof nextIndex !== 'number') {
if (direction) {
- nextIndex = index + slidesToScroll;
+ if (infinite && index + infinite * 2 !== slides.length) {
+ nextIndex = index + (infinite - index % infinite);
+ } else {
+ nextIndex = index + slidesToScroll;
+ }
} else {
- nextIndex = index - slidesToScroll;
+ if (infinite && index % infinite !== 0) {
+ nextIndex = index - index % infinite;
+ } else {
+ nextIndex = index - slidesToScroll;
+ }
}
}
nextIndex = Math.min(Math.max(nextIndex, 0), slides.length - 1);
@@ -319,10 +327,10 @@
*/
if (slides[nextIndex].offsetLeft <= maxOffset) {
index = nextIndex;
}
- if (infinite && (nextIndex === slides.length - infinite || nextIndex === 0)) {
+ if (infinite && (nextIndex === slides.length - infinite || nextIndex === slides.length - slides.length % infinite || nextIndex === 0)) {
if (direction) {
index = infinite;
}
if (!direction) {
\ No newline at end of file