v1.18.x
barisusakli 9 years ago
parent 3b9120cd38
commit 3a27e7b0ea

@ -222,10 +222,10 @@ define('forum/topic', [
function updateTopicTitle() { function updateTopicTitle() {
var span = components.get('navbar/title').find('span'); var span = components.get('navbar/title').find('span');
if ($(window).scrollTop() > 50) { if ($(window).scrollTop() > 50 && span.hasClass('hidden')) {
span.html(ajaxify.data.title).show(); span.html(ajaxify.data.title).removeClass('hidden');
} else { } else if ($(window).scrollTop() <= 50 && !span.hasClass('hidden')) {
span.html('').hide(); span.html('').addClass('hidden');
} }
if ($(window).scrollTop() > 300) { if ($(window).scrollTop() > 300) {
app.removeAlert('bookmark'); app.removeAlert('bookmark');

@ -103,7 +103,10 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
index = parseInt(els.first().attr('data-index'), 10) + 1; index = parseInt(els.first().attr('data-index'), 10) + 1;
} }
var middleOfViewport = $(window).scrollTop() + $(window).height() / 2; var scrollTop = $(window).scrollTop();
var windowHeight = $(window).height();
var documentHeight = $(document).height();
var middleOfViewport = scrollTop + windowHeight / 2;
var previousDistance = Number.MAX_VALUE; var previousDistance = Number.MAX_VALUE;
els.each(function() { els.each(function() {
var distanceToMiddle = Math.abs(middleOfViewport - $(this).offset().top); var distanceToMiddle = Math.abs(middleOfViewport - $(this).offset().top);
@ -118,10 +121,19 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
} }
}); });
// check if we are at the top
if (scrollTop === 0 && parseInt(els.first().attr('data-index'), 10) === 0) {
index = 1;
// check if we are near the bottom
} else if (scrollTop + windowHeight > documentHeight - 100 && parseInt(els.last().attr('data-index'), 10) === count - 1) {
index = count;
}
// If a threshold is undefined, try to determine one based on new index // If a threshold is undefined, try to determine one based on new index
if (threshold === undefined) { if (threshold === undefined) {
var anchorEl = components.get('post/anchor', index - 1), var anchorEl = components.get('post/anchor', index - 1);
anchorRect = anchorEl.get(0).getBoundingClientRect(); var anchorRect = anchorEl.get(0).getBoundingClientRect();
threshold = anchorRect.top; threshold = anchorRect.top;
} }

Loading…
Cancel
Save