v1.18.x
Barış Soner Uşaklı 4 years ago
parent e362c342a3
commit c107649b40

@ -275,6 +275,10 @@ ajaxify = window.ajaxify || {};
}
ajaxify.end = function (url, tpl_url) {
// Scroll back to top of page
if (!ajaxify.isCold()) {
window.scrollTo(0, 0);
}
ajaxify.loadScript(tpl_url, function done() {
$(window).trigger('action:ajaxify.end', { url: url, tpl_url: tpl_url, title: ajaxify.data.title });
});

@ -284,11 +284,6 @@ app.cacheBuster = null;
app.createUserTooltips($('#content'));
app.createStatusTooltips();
// Scroll back to top of page
if (!ajaxify.isCold()) {
window.scrollTo(0, 0);
}
};
app.showMessages = function () {

@ -222,7 +222,9 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
var scrollTop = $(window).scrollTop();
var windowHeight = $(window).height();
var documentHeight = $(document).height();
var middleOfViewport = scrollTop + (windowHeight / 2);
var navbarHeight = components.get('navbar').outerHeight(true);
var topicHeaderHeight = $('.topic-header').height() || 0;
var middleOfViewport = scrollTop + (windowHeight / 2) - navbarHeight - topicHeaderHeight;
var previousDistance = Number.MAX_VALUE;
els.each(function () {
var elIndex = parseInt($(this).attr('data-index'), 10);
@ -387,23 +389,27 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
return;
}
var postHeight = scrollTo.height();
var viewportHeight = $(window).height();
var navbarHeight = components.get('navbar').height();
var navbarHeight = components.get('navbar').outerHeight(true);
var topicHeaderHeight = $('.topic-header').height() || 0;
var viewportHeight = $(window).height() - navbarHeight - topicHeaderHeight;
// Temporarily disable navigator update on scroll
$(window).off('scroll', navigator.update);
$(window).off('scroll', navigator.delayedUpdate);
duration = duration !== undefined ? duration : 400;
navigator.scrollActive = true;
var done = false;
function animateScroll() {
function onAnimateComplete() {
if (done) {
function reenableScroll() {
// Re-enable onScroll behaviour
$(window).on('scroll', navigator.update);
$(window).on('scroll', navigator.delayedUpdate);
var scrollToRect = scrollTo.get(0).getBoundingClientRect();
navigator.update(scrollToRect.top);
}
function onAnimateComplete() {
if (done) {
reenableScroll();
return;
}
done = true;
@ -416,13 +422,16 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
var scrollTop = 0;
if (postHeight < viewportHeight) {
scrollTop = (scrollTo.offset().top - (viewportHeight / 2) + (postHeight / 2));
scrollTop = (scrollTo.offset().top - (viewportHeight / 2) + (postHeight / 2)) - topicHeaderHeight;
} else {
scrollTop = scrollTo.offset().top - navbarHeight;
scrollTop = scrollTo.offset().top - navbarHeight - topicHeaderHeight;
}
if (duration === 0) {
$(window).scrollTop(scrollTop);
return onAnimateComplete();
onAnimateComplete();
reenableScroll();
return;
}
$('html, body').animate({
scrollTop: scrollTop + 'px',
@ -444,3 +453,4 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
return navigator;
});

Loading…
Cancel
Save