Fixing viewport shuffling due to image load

Introduced new method ".loadImages()" in posts client side lib
to handle viewport height changes when loading images. Requires
nodebb-plugin-markdown@5.0.0

@BenLubar @boomzillawtf
This commit is contained in:
Julian Lam
2016-03-27 15:52:26 -04:00
parent 5d4f61ec96
commit 3e2231d2cb
7 changed files with 126 additions and 13 deletions

View File

@@ -61,12 +61,12 @@ define('forum/topic', [
addParentHandler();
handleBookmark(tid);
handleKeys();
navigator.init('[component="post/anchor"]', ajaxify.data.postcount, Topic.toTop, Topic.toBottom, Topic.navigatorCallback, Topic.calculateIndex);
handleBookmark(tid);
$(window).on('scroll', updateTopicTitle);
handleTopicSearch();
@@ -141,6 +141,7 @@ define('forum/topic', [
return navigator.scrollToPostIndex(postIndex, true);
}
} else if (bookmark && (!config.usePagination || (config.usePagination && ajaxify.data.pagination.currentPage === 1)) && ajaxify.data.postcount > 5) {
navigator.update();
app.alert({
alert_id: 'bookmark',
message: '[[topic:bookmark_instructions]]',
@@ -156,6 +157,8 @@ define('forum/topic', [
setTimeout(function() {
app.removeAlert('bookmark');
}, 10000);
} else {
navigator.update();
}
}
@@ -233,7 +236,7 @@ define('forum/topic', [
return index;
};
Topic.navigatorCallback = function(index, elementCount) {
Topic.navigatorCallback = function(index, elementCount, threshold) {
var path = ajaxify.removeRelativePath(window.location.pathname.slice(1));
if (!path.startsWith('topic')) {
return 1;
@@ -248,13 +251,13 @@ define('forum/topic', [
newUrl += '/' + index;
}
posts.loadImages(threshold);
if (newUrl !== currentUrl) {
if (Topic.replaceURLTimeout) {
clearTimeout(Topic.replaceURLTimeout);
}
Topic.replaceURLTimeout = setTimeout(function() {
updateUserBookmark(index);
Topic.replaceURLTimeout = 0;