diff --git a/public/src/client/topic.js b/public/src/client/topic.js index 14a3313f7b..95b84204fe 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -82,7 +82,8 @@ define('forum/topic', [ function handleBookmark(tid) { var bookmark = localStorage.getItem('topic:' + tid + ':bookmark'); var postIndex = getPostIndex(); - if (postIndex) { + + if (postIndex && window.location.search.indexOf('page=') === -1) { navigator.scrollToPost(postIndex - 1, true); } else if (bookmark && (!config.usePagination || (config.usePagination && pagination.currentPage === 1)) && ajaxify.variables.get('postcount') > 1) { app.alert({ diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index 30c83ec10a..add1b41b04 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -106,6 +106,10 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com } }); + if (topIndex && !bottomIndex) { + bottomIndex = topIndex; + } + if (typeof navigator.callback === 'function' && topIndex && bottomIndex) { index = navigator.callback(topIndex, bottomIndex, count); navigator.updateTextAndProgressBar(); @@ -169,17 +173,13 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com duration = duration !== undefined ? duration : 400; navigator.scrollActive = true; - if(components.get('post/anchor', postIndex).length) { + if (components.get('post/anchor', postIndex).length) { return scrollToPid(postIndex, highlight, duration, offset); } if (config.usePagination) { - if (window.location.search.indexOf('page') !== -1) { - navigator.update(); - return; - } - var page = Math.ceil((postIndex + 1) / config.postsPerPage); + var page = Math.max(1, Math.ceil(postIndex / config.postsPerPage)); if(parseInt(page, 10) !== pagination.currentPage) { pagination.loadPage(page, function() { @@ -198,7 +198,7 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com function scrollToPid(postIndex, highlight, duration, offset) { var scrollTo = components.get('post/anchor', postIndex); - if (!scrollTo) { + if (!scrollTo.length) { navigator.scrollActive = false; return; }