Fix auto_remove_article (#2334)

* Fix auto_remove_article

https://github.com/FreshRSS/FreshRSS/issues/2323

* Second attempt

* Third attempt
pull/2337/head
Alexandre Alapetite 6 years ago committed by GitHub
parent 59b326040a
commit 452419bf83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      p/scripts/main.js

@ -590,23 +590,24 @@ function onScroll() {
});
}
if (context.auto_remove_article) {
let maxTop = box_to_follow.scrollTop,
scrollOffset = 0;
document.querySelectorAll('.flux:not(.active):not(.keep_unread)').forEach(function (div) {
let scrollTop = box_to_follow.scrollTop;
let dirty = false;
document.querySelectorAll('.flux:not(.active):not(.not_read)').forEach(function (div) {
if (!pending_entries[div.id] && div.offsetHeight > 0 &&
div.offsetParent.offsetTop + div.offsetTop + div.offsetHeight < maxTop) {
div.offsetParent.offsetTop + div.offsetTop + (div.offsetHeight * 2) < scrollTop) {
const p = div.previousElementSibling,
n = div.nextElementSibling;
if (p && p.classList.contains('day') && n && n.classList.contains('day')) {
scrollTop -= p.offsetHeight;
p.remove();
}
maxTop -= div.offsetHeight;
scrollOffset -= div.offsetHeight;
scrollTop -= div.offsetHeight;
div.remove();
dirty = true;
}
});
if (scrollOffset != 0) {
box_to_follow.scrollTop += scrollOffset;
if (dirty) {
box_to_follow.scrollTop = scrollTop;
return; //onscroll will be called again
}
}

Loading…
Cancel
Save