From 9f8b8a1c3a482594d6ddaca8557037fcc7eeee4b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 9 Jun 2016 12:16:54 -0400 Subject: [PATCH] FIX: Couldn't track some post positions properly --- .../discourse/components/scrolling-post-stream.js.es6 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/scrolling-post-stream.js.es6 b/app/assets/javascripts/discourse/components/scrolling-post-stream.js.es6 index 2ee09d5be26..994626ae8c8 100644 --- a/app/assets/javascripts/discourse/components/scrolling-post-stream.js.es6 +++ b/app/assets/javascripts/discourse/components/scrolling-post-stream.js.es6 @@ -94,6 +94,7 @@ export default MountWidget.extend({ let allAbove = true; let bottomView = topView; + let lastBottom = 0; while (bottomView < $posts.length) { const post = $posts[bottomView]; const $post = $(post); @@ -112,11 +113,14 @@ export default MountWidget.extend({ onscreen.push(bottomView); } - if (currentPost === null && (viewTop <= topCheck) && (viewBottom >= topCheck)) { + if ((currentPost === null) && + ((viewTop <= topCheck && viewBottom >= topCheck) || + (lastBottom <= topCheck && viewTop >= topCheck))) { percent = (topCheck - viewTop) / postHeight; currentPost = bottomView; } + lastBottom = viewBottom; nearby.push(bottomView); bottomView++; }