more tweaks to threshold

This commit is contained in:
Julian Lam
2016-03-28 14:50:02 -04:00
parent 31e70ac5a8
commit 1783a07067
2 changed files with 6 additions and 3 deletions

View File

@@ -10,7 +10,9 @@ define('forum/topic/posts', [
'components'
], function(pagination, infinitescroll, postTools, navigator, components) {
var Posts = {};
var Posts = {
_threshold: 0
};
Posts.onNewPost = function(data) {
if (!data || !data.posts || !data.posts.length) {
@@ -255,6 +257,7 @@ define('forum/topic/posts', [
If no threshold is defined, loaded images will push down content, as per
default
*/
Posts._threshold = threshold;
var images = components.get('post/content').find('img[data-state="unloaded"]'),
visible = images.filter(function() {
@@ -272,7 +275,7 @@ define('forum/topic/posts', [
newHeight = document.body.clientHeight;
var imageRect = this.getBoundingClientRect();
if (imageRect.top < threshold) {
if (imageRect.top < Posts._threshold) {
scrollTop = scrollTop + (newHeight - oldHeight);
$(window).scrollTop(scrollTop);
}