Skip to content

Commit e151df9

Browse files
committed
Merge pull request jquerytools#412 from jessecarl/master
Scrollable with one or zero items (and particularly with circular true)
2 parents 0046c59 + 9abf5af commit e151df9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/scrollable/scrollable.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,12 @@
192192
};
193193
});
194194

195+
// next/prev buttons
196+
var prev = find(root, conf.prev).click(function() { self.prev(); }),
197+
next = find(root, conf.next).click(function() { self.next(); });
198+
195199
// circular loop
196-
if (conf.circular) {
200+
if (conf.circular && self.getSize() > 1) {
197201

198202
var cloned1 = self.getItems().slice(-1).clone().prependTo(itemWrap),
199203
cloned2 = self.getItems().eq(1).clone().appendTo(itemWrap);
@@ -225,13 +229,8 @@
225229

226230
// seek over the cloned item
227231
self.seekTo(0, 0, function() {});
228-
}
229-
230-
// next/prev buttons
231-
var prev = find(root, conf.prev).click(function() { self.prev(); }),
232-
next = find(root, conf.next).click(function() { self.next(); });
233-
234-
if (!conf.circular && self.getSize() > 1) {
232+
233+
} else if (!conf.circular && self.getSize() > 1) {
235234

236235
self.onBeforeSeek(function(e, i) {
237236
setTimeout(function() {
@@ -245,6 +244,9 @@
245244
if (!conf.initialIndex) {
246245
prev.addClass(conf.disabledClass);
247246
}
247+
} else { // the case where there is one or zero items
248+
prev.addClass(conf.disabledClass);
249+
next.addClass(conf.disabledClass);
248250
}
249251

250252
// mousewheel support

0 commit comments

Comments
 (0)