From cfa91dcf0aa25766dedfaa0205dc697389d07f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 5 Sep 2018 09:36:44 +0200 Subject: Fix mark as read on scroll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- js/directive/NewsScroll.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/directive/NewsScroll.js b/js/directive/NewsScroll.js index d83317fcb..552c7411f 100644 --- a/js/directive/NewsScroll.js +++ b/js/directive/NewsScroll.js @@ -47,9 +47,10 @@ app.directive('newsScroll', function ($timeout, ITEM_AUTO_PAGE_SIZE, var articles = elem.querySelectorAll('.item:not(.read)'); articles.forEach(function(article) { - var distTop = article.getBoundingClientRect().top; - var scrollTop = $(document).scrollTop(); - if (distTop - scrollTop <= -10) { + var distTop = article.offsetTop; + var scrollTop = window.pageYOffset || + document.documentElement.scrollTop; + if (distTop < scrollTop - 50) { ids.push(parseInt(article.dataset.id, 10)); } else { return false; -- cgit v1.2.3