mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 13:31:44 +08:00
Merge pull request #4163 from frictionel/keyboard-shortcuts2
FIX: position view on `j`+`k` keyboard shortcuts
This commit is contained in:
commit
e4e37fe70c
|
@ -327,15 +327,17 @@ export default {
|
|||
// Try to keep the article on screen
|
||||
const pos = $article.offset();
|
||||
const height = $article.height();
|
||||
const headerHeight = $('header.d-header').height();
|
||||
const scrollTop = $(window).scrollTop();
|
||||
const windowHeight = $(window).height();
|
||||
|
||||
// skip if completely on screen
|
||||
if (pos.top > scrollTop && (pos.top + height) < (scrollTop + windowHeight)) {
|
||||
if ((pos.top - headerHeight) > scrollTop && (pos.top + height) < (scrollTop + windowHeight)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let scrollPos = (pos.top + (height/2)) - (windowHeight * 0.5);
|
||||
if (height > (windowHeight - headerHeight)) { scrollPos = (pos.top - headerHeight); }
|
||||
if (scrollPos < 0) { scrollPos = 0; }
|
||||
|
||||
if (this._scrollAnimation) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user