FIX: J/K keyboard shortcut misbehaving
This commit is contained in:
parent
62aacce8f4
commit
41150fc0cd
|
@ -311,9 +311,7 @@ export default {
|
||||||
_moveSelection(direction) {
|
_moveSelection(direction) {
|
||||||
const $articles = this._findArticles();
|
const $articles = this._findArticles();
|
||||||
|
|
||||||
if (typeof $articles === 'undefined') {
|
if (typeof $articles === 'undefined') return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const $selected = ($articles.filter('.selected').length !== 0)
|
const $selected = ($articles.filter('.selected').length !== 0)
|
||||||
? $articles.filter('.selected')
|
? $articles.filter('.selected')
|
||||||
|
@ -322,27 +320,15 @@ export default {
|
||||||
let index = $articles.index($selected);
|
let index = $articles.index($selected);
|
||||||
|
|
||||||
if ($selected.length !== 0) {
|
if ($selected.length !== 0) {
|
||||||
if (direction === -1 && index === 0) { return; }
|
if (direction === -1 && index === 0) return;
|
||||||
if (direction === 1 && index === ($articles.length - 1) ) { return; }
|
if (direction === 1 && index === $articles.length - 1) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if nothing is selected go to the first post on screen
|
// when nothing is selected
|
||||||
if ($selected.length === 0) {
|
if ($selected.length === 0) {
|
||||||
const scrollTop = $(document).scrollTop();
|
// select the first post with its top visible
|
||||||
|
const offset = minimumOffset();
|
||||||
index = 0;
|
index = $articles.toArray().findIndex(article => article.getBoundingClientRect().top > offset);
|
||||||
$articles.each(function() {
|
|
||||||
const top = $(this).position().top;
|
|
||||||
if (top >= scrollTop) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
index += 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (index >= $articles.length) {
|
|
||||||
index = $articles.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
direction = 0;
|
direction = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +348,11 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
_scrollToPost($article) {
|
_scrollToPost($article) {
|
||||||
$(window).scrollTop($article.offset().top - minimumOffset());
|
if ($article.find("#post_1").length > 0) {
|
||||||
|
$(window).scrollTop(0);
|
||||||
|
} else {
|
||||||
|
$(window).scrollTop($article.offset().top - minimumOffset());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_scrollList($article) {
|
_scrollList($article) {
|
||||||
|
@ -390,14 +380,13 @@ export default {
|
||||||
|
|
||||||
|
|
||||||
_findArticles() {
|
_findArticles() {
|
||||||
const $topicList = $('.topic-list'),
|
const $topicList = $(".topic-list");
|
||||||
$topicArea = $('.posts-wrapper');
|
const $postsWrapper = $(".posts-wrapper");
|
||||||
|
|
||||||
if ($topicArea.length > 0) {
|
if ($postsWrapper.length > 0) {
|
||||||
return $('.posts-wrapper .topic-post, .topic-list tbody tr');
|
return $(".posts-wrapper .topic-post, .topic-list tbody tr");
|
||||||
}
|
} else if ($topicList.length > 0) {
|
||||||
else if ($topicList.length > 0) {
|
return $topicList.find(".topic-list-item");
|
||||||
return $topicList.find('.topic-list-item');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue