diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-27 18:23:41 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-27 18:23:41 +0200 |
commit | ebb5a2f442ff0d9547b2fe8da686fb334e02e2f7 (patch) | |
tree | 1ddda63fd669b5bd1023d1b51c3333f96a347e8a /js/app/directives | |
parent | cd2488ee421c5f4d09ddc7ef6484409659aa17c8 (diff) |
autopage by item fix #136
Diffstat (limited to 'js/app/directives')
-rw-r--r-- | js/app/directives/newsitemscroll.coffee | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/js/app/directives/newsitemscroll.coffee b/js/app/directives/newsitemscroll.coffee index 619710bf3..5d8345999 100644 --- a/js/app/directives/newsitemscroll.coffee +++ b/js/app/directives/newsitemscroll.coffee @@ -57,10 +57,23 @@ angular.module('News').directive 'newsItemScroll', ['$rootScope', 'Config', , Config.MarkReadTimeout # autopaging - tolerance = elm.height() * Config.autoPageFactor - remaining = elm[0].scrollHeight - elm.scrollTop() - tolerance - if remaining <= 0 - $rootScope.$broadcast 'autoPage' + counter = 0 + + # run from the bottom up to be performant + for item in elm.find('.feed_item') by -1 + + # if the counter is 10 it means that it didnt break to auto + # page yet and that there are more than 10 items, so break + if counter >= Config.autoPageFactor + break + + # this is only reached when the item is not is below the top + # and we didnt hit the factor yet so autopage and break + if $(item).position().top < 0 + $rootScope.$broadcast 'autoPage' + break + + counter += 1 ] |