aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-10-16 12:31:13 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-10-16 12:31:13 +0200
commitce14841cc05e500819c0cdb2c594be8b44e91e2d (patch)
tree4dcfcb8540e6ce0d84ebf5a1b18c006b56686df4 /p/scripts
parentdbffbc18222caa9259733b8c57950147008892d0 (diff)
Scroll as read for Global view + throttle event
https://github.com/FreshRSS/FreshRSS/issues/1317 https://github.com/FreshRSS/FreshRSS/pull/1309
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js28
1 files changed, 12 insertions, 16 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index b3531e884..400abf947 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -449,26 +449,22 @@ function auto_share(key) {
}
}
-function inMarkViewport(flux, box_to_follow) {
- var bottom = flux.offset().top + flux.height(),
- windowTop = box_to_follow.scrollTop();
- return bottom < windowTop + 40;
-}
-
function init_posts() {
- var box_to_follow = $(window);
- if (context.current_view === 'global') {
- box_to_follow = $("#panel");
- }
+ var box_to_follow = context.current_view === 'global' ? $("#panel") : $(window);
if (context.auto_mark_scroll) {
+ var lastScroll = 0; //Throttle
box_to_follow.scroll(function () {
- $('.not_read:visible').each(function () {
- var $this = $(this);
- if (inMarkViewport($this, box_to_follow)) {
- mark_read($this, true);
- }
- });
+ if (lastScroll + 500 < Date.now()) {
+ lastScroll = Date.now();
+ $('.not_read:visible').each(function () {
+ var $this = $(this),
+ minTop = (context.current_view === 'global') ? box_to_follow.offset().top : box_to_follow.scrollTop();
+ if ($this.offset().top + $this.height() < minTop + 40) {
+ mark_read($this, true);
+ }
+ });
+ }
});
}