diff --git a/public/src/client/pagination.js b/public/src/client/pagination.js index 1fba9d354d..543f7534b7 100644 --- a/public/src/client/pagination.js +++ b/public/src/client/pagination.js @@ -27,5 +27,13 @@ define('forum/pagination', function () { ajaxify.go(url, callback); }; + pagination.nextPage = function (callback) { + pagination.loadPage(ajaxify.data.pagination.currentPage + 1, callback); + }; + + pagination.previousPage = function (callback) { + pagination.loadPage(ajaxify.data.pagination.currentPage - 1, callback); + }; + return pagination; }); diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index 05ada15e81..c83a45ce3d 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -212,14 +212,32 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co } navigator.scrollUp = function () { + var $window = $(window); + + if (config.usePagination) { + var atTop = $window.scrollTop() <= 0; + if (atTop) { + return pagination.previousPage(function () { + $('body,html').scrollTop($(document).height() - $window.height()); + }); + } + } $('body,html').animate({ - scrollTop: $(window).scrollTop() - $(window).height(), + scrollTop: $window.scrollTop() - $window.height(), }); }; navigator.scrollDown = function () { + var $window = $(window); + + if (config.usePagination) { + var atBottom = $window.scrollTop() >= $(document).height() - $window.height(); + if (atBottom) { + return pagination.nextPage(); + } + } $('body,html').animate({ - scrollTop: $(window).scrollTop() + $(window).height(), + scrollTop: $window.scrollTop() + $window.height(), }); };