scrollToPost / scrollToPostIndex offset isn't used anymore

v1.18.x
psychobunny 10 years ago
parent 9fc80702b8
commit 714efd0d0e

@ -147,17 +147,16 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
} }
}; };
navigator.scrollToPost = function(postIndex, highlight, duration, offset) { navigator.scrollToPost = function(postIndex, highlight, duration) {
if (!utils.isNumber(postIndex) || !components.get('topic').length) { if (!utils.isNumber(postIndex) || !components.get('topic').length) {
return; return;
} }
offset = offset || 0;
duration = duration !== undefined ? duration : 400; duration = duration !== undefined ? duration : 400;
navigator.scrollActive = true; navigator.scrollActive = true;
if (components.get('post/anchor', postIndex).length) { if (components.get('post/anchor', postIndex).length) {
return navigator.scrollToPostIndex(postIndex, highlight, duration, offset); return navigator.scrollToPostIndex(postIndex, highlight, duration);
} }
if (config.usePagination) { if (config.usePagination) {
@ -165,10 +164,10 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
if (parseInt(page, 10) !== pagination.currentPage) { if (parseInt(page, 10) !== pagination.currentPage) {
pagination.loadPage(page, function() { pagination.loadPage(page, function() {
navigator.scrollToPostIndex(postIndex, highlight, duration, offset); navigator.scrollToPostIndex(postIndex, highlight, duration);
}); });
} else { } else {
navigator.scrollToPostIndex(postIndex, highlight, duration, offset); navigator.scrollToPostIndex(postIndex, highlight, duration);
} }
} else { } else {
navigator.scrollActive = false; navigator.scrollActive = false;
@ -177,19 +176,20 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
} }
}; };
navigator.scrollToPostIndex = function(postIndex, highlight, duration, offset) { navigator.scrollToPostIndex = function(postIndex, highlight, duration) {
var scrollTo = components.get('post/anchor', postIndex); var scrollTo = components.get('post/anchor', postIndex);
if (!scrollTo.length) { if (!scrollTo.length) {
navigator.scrollActive = false; navigator.scrollActive = false;
return; return;
} }
offset = offset || 0;
duration = duration !== undefined ? duration : 400; duration = duration !== undefined ? duration : 400;
navigator.scrollActive = true; navigator.scrollActive = true;
var done = false; var done = false;
function animateScroll() { function animateScroll() {
var scrollTop = (scrollTo.offset().top - ($(window).height() / 2) - offset) + 'px'; var scrollTop = (scrollTo.offset().top - ($(window).height() / 2)) + 'px';
$('html, body').animate({ $('html, body').animate({
scrollTop: scrollTop scrollTop: scrollTop

Loading…
Cancel
Save