From ef84343576f671163b11811f59294e72e1da2b36 Mon Sep 17 00:00:00 2001 From: Aidi Tan <3037661+aidistan@users.noreply.github.com> Date: Sat, 27 Aug 2022 17:11:41 +0800 Subject: Fix #4231 (#4541) Actually, there are two issues to be fixed: 1. Since `div.flux_content` has been changed to `article.flux_content` in HTML, we should address that in JS too. Or, to take one step further, select it using `.flux_content` directly. 2. For the article already at the first position, its `prev_article` would select `#new-article` whose css attribute `display` is `none` in most cases, which breaks the new position calculation. --- p/scripts/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 1619993c4..ad3224507 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -435,7 +435,7 @@ function toggleContent(new_active, old_active, skipping) { let new_pos = new_active.offsetParent.offsetTop + new_active.offsetTop - nav_menu_height; - if (prev_article && new_active.offsetTop - prev_article.offsetTop <= 150) { + if (prev_article && prev_article.offsetParent && new_active.offsetTop - prev_article.offsetTop <= 150) { new_pos = prev_article.offsetParent.offsetTop + prev_article.offsetTop - nav_menu_height; if (relative_move) { new_pos -= box_to_move.offsetTop; @@ -1103,7 +1103,7 @@ function init_stream(stream) { if (ev.target.closest('.content, .item.website, .item.link, .dropdown')) { return true; } - if (!context.sides_close_article && ev.target.matches('div.flux_content')) { + if (!context.sides_close_article && ev.target.matches('.flux_content')) { // setting for not-closing after clicking outside article area return false; } -- cgit v1.2.3