diff --git a/__test__/pagination.test.js b/__test__/pagination.test.js index d06a038a..ca988382 100644 --- a/__test__/pagination.test.js +++ b/__test__/pagination.test.js @@ -92,6 +92,14 @@ describe('Pagination', function() { expect($(pagination.find('li').get(2)).hasClass('active')).toEqual(false); expect($(pagination.find('li').get(3)).hasClass('active')).toEqual(true); }); + + it('should handle page = 0', function() { + expect(pagination.is(':visible')).toBe(true); + list.show(0, 0); + expect(pagination.is(':visible')).toBe(false); + list.show(1, 1); + expect(pagination.is(':visible')).toBe(true); + }); }); diff --git a/src/pagination.js b/src/pagination.js index ec3baaaa..1ef314a1 100644 --- a/src/pagination.js +++ b/src/pagination.js @@ -3,8 +3,17 @@ var classes = require('./utils/classes'), List = require('./index'); module.exports = function(list) { + var isHidden = false; var refresh = function(pagingList, options) { + if (list.page < 1) { + list.listContainer.style.display = 'none'; + isHidden = true + return; + } else if (isHidden){ + list.listContainer.style.display = 'block'; + } + var item, l = list.matchingItems.length, index = list.i, @@ -16,7 +25,6 @@ module.exports = function(list) { right = options.right || options.outerWindow || 0; right = pages - right; - pagingList.clear(); for (var i = 1; i <= pages; i++) { var className = (currentPage === i) ? "active" : "";