diff --git a/examples/index.html b/examples/index.html
index e7ad28e..56cc436 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -303,6 +303,37 @@
Source
}).on('page', function(event, num){
// ... load content from the server and update DOM
$(".content3").html("Dynamic content for Page #" + num);
+});
+
+ maxVisible: 1 example
+
+ Only one page number visible at a time.
+ Use prev/next to navigate all 10 pages.
+
+
+
+ Dynamic content here.
+
+
+
+ Source
+
+
+
+
+
+
+
$('.demo5').bootpag({
+ total: 10,
+ maxVisible: 1
+}).on('page', function(event, num){
+ $(".content5").html("Dynamic content for Page #" + num);
});
Full example
@@ -386,6 +417,14 @@ Source
.on("page", function (event, num) {
$(".content3").html("Dynamic content for Page #" + num); // or load content from the server
});
+ $(".demo5")
+ .bootpag({
+ total: 10,
+ maxVisible: 1,
+ })
+ .on("page", function (event, num) {
+ $(".content5").html("Dynamic content for Page #" + num);
+ });
$(".demo4_top,.demo4_bottom")
.bootpag({
total: 50,
diff --git a/src/jquery.bootpag.js b/src/jquery.bootpag.js
index a188872..1f19dba 100644
--- a/src/jquery.bootpag.js
+++ b/src/jquery.bootpag.js
@@ -118,7 +118,7 @@
.find('a').attr('href', href(lp));
}
- step = settings.maxVisible == 1 ? 0 : 1;
+ step = 1;
lp = page + 1 > settings.total ? settings.total :
settings.leaps && page + 1 <= settings.total - settings.maxVisible ?
diff --git a/test/bootpag.test.js b/test/bootpag.test.js
index ffe496e..2a626ff 100644
--- a/test/bootpag.test.js
+++ b/test/bootpag.test.js
@@ -156,6 +156,15 @@ describe('Leaps', () => {
expect(handler.mock.calls[0][1]).toBe(6);
});
+ test('with maxVisible: 1, next advances to the next page', () => {
+ var handler = jest.fn();
+ $('#pag').bootpag({ total: 5, maxVisible: 1, leaps: true }).on('page', handler);
+ $('#pag li.next').trigger('click');
+ expect(handler).toHaveBeenCalledTimes(1);
+ expect(handler.mock.calls[0][1]).toBe(2);
+ expect($('#pag li.active').attr('data-lp')).toBe('2');
+ });
+
test('with leaps: false, next advances by 1', () => {
var handler = jest.fn();
$('#pag').bootpag({ total: 20, maxVisible: 5, leaps: false }).on('page', handler);