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

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

@ -103,7 +103,10 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
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;
els.each(function() {
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 (threshold === undefined) {
var anchorEl = components.get('post/anchor', index - 1),
anchorRect = anchorEl.get(0).getBoundingClientRect();
var anchorEl = components.get('post/anchor', index - 1);
var anchorRect = anchorEl.get(0).getBoundingClientRect();
threshold = anchorRect.top;
}

Loading…
Cancel
Save