diff options
| author | 2016-01-26 22:00:18 +0100 | |
|---|---|---|
| committer | 2016-01-26 22:00:18 +0100 | |
| commit | f62ab5fe5bb15a846a653e291f42828df090426e (patch) | |
| tree | e882b593eacfd351719fd73032c59fd9cd2cfc0b /p/scripts | |
| parent | 159ea0aecf2f3738da4fdf70e7e0aaffade60dcc (diff) | |
Offset in global view
https://github.com/FreshRSS/FreshRSS/pull/1050#issuecomment-175166593
Diffstat (limited to 'p/scripts')
| -rw-r--r-- | p/scripts/main.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js index 45a028a7d..968c945c8 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -244,20 +244,19 @@ function toggleContent(new_active, old_active) { new_active.toggleClass('active'); } - var box_to_move = "html,body", - relative_move = false; - if (context['current_view'] === 'global') { - box_to_move = "#panel"; - relative_move = true; - } + var relative_move = context['current_view'] === 'global', + box_to_move = $(relative_move ? "#panel" : "html,body"); if (context['sticky_post']) { var prev_article = new_active.prevAll('.flux'), new_pos = new_active.offset().top, - old_scroll = $(box_to_move).scrollTop(); + old_scroll = box_to_move.scrollTop(); if (prev_article.length > 0 && new_pos - prev_article.offset().top <= 150) { new_pos = prev_article.offset().top; + if (relative_move) { + new_pos -= box_to_move.offset().top; + } } if (context['hide_posts']) { @@ -267,7 +266,7 @@ function toggleContent(new_active, old_active) { if (old_active[0] !== new_active[0]) { new_active.children(".flux_content").first().each(function () { - $(box_to_move).scrollTop(new_pos).scrollTop(); + box_to_move.scrollTop(new_pos).scrollTop(); }); } } else { @@ -275,7 +274,7 @@ function toggleContent(new_active, old_active) { new_pos += old_scroll; } - $(box_to_move).scrollTop(new_pos).scrollTop(); + box_to_move.scrollTop(new_pos).scrollTop(); } } |
