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