From 259dcbe5a0179582988c50cfaea77b68af10bb9d Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 14 Aug 2013 12:15:19 +0200 Subject: When jumping to the next item after the last one, also mark the last item as read, fix #213 --- js/app/directives/itemshortcuts.coffee | 7 +++++++ js/public/app.js | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/app/directives/itemshortcuts.coffee b/js/app/directives/itemshortcuts.coffee index 076da571e..d78af0c15 100644 --- a/js/app/directives/itemshortcuts.coffee +++ b/js/app/directives/itemshortcuts.coffee @@ -52,11 +52,18 @@ angular.module('News').directive 'itemShortcuts', ['$window', ($window) -> jumpToNextItem = (scrollArea) -> $scrollArea = $(scrollArea) $items = $scrollArea.find('.feed_item') + jumped = false for item in $items $item = $(item) if $item.position().top > 1 + jumped = true jumpTo($scrollArea, $item) break + # in case this is the last item it should still scroll below the + # top + if jumped == false + $scrollArea.scrollTop($scrollArea.prop('scrollHeight')) + getCurrentItem = (scrollArea) -> diff --git a/js/public/app.js b/js/public/app.js index 39cd509c4..33c54c0e5 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -225,21 +225,22 @@ License along with this library. If not, see . } }; jumpToNextItem = function(scrollArea) { - var $item, $items, $scrollArea, item, _i, _len, _results; + var $item, $items, $scrollArea, item, jumped, _i, _len; $scrollArea = $(scrollArea); $items = $scrollArea.find('.feed_item'); - _results = []; + jumped = false; for (_i = 0, _len = $items.length; _i < _len; _i++) { item = $items[_i]; $item = $(item); if ($item.position().top > 1) { + jumped = true; jumpTo($scrollArea, $item); break; - } else { - _results.push(void 0); } } - return _results; + if (jumped === false) { + return $scrollArea.scrollTop($scrollArea.prop('scrollHeight')); + } }; getCurrentItem = function(scrollArea) { var $item, $items, $scrollArea, item, _i, _len; -- cgit v1.2.3