mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #4163 from frictionel/keyboard-shortcuts2
FIX: position view on `j`+`k` keyboard shortcuts
This commit is contained in:
commit
e4e37fe70c
1 changed files with 3 additions and 1 deletions
|
@ -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 a new issue