mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
Wrap around when navigating with keyboard shortcuts on a list view
This commit is contained in:
parent
86e71c48f5
commit
1a78e3a5bc
2 changed files with 24 additions and 15 deletions
|
@ -404,25 +404,29 @@ function goToPreviousListItem() {
|
|||
if (items[i].classList.contains("current-item")) {
|
||||
items[i].classList.remove("current-item");
|
||||
|
||||
let nextItem;
|
||||
if (i - 1 >= 0) {
|
||||
items[i - 1].classList.add("current-item");
|
||||
DomHelper.scrollPageTo(items[i - 1]);
|
||||
items[i - 1].querySelector('.item-header a').focus();
|
||||
nextItem = items[i - 1];
|
||||
} else {
|
||||
nextItem = items[items.length - 1];
|
||||
}
|
||||
|
||||
nextItem.classList.add("current-item");
|
||||
DomHelper.scrollPageTo(nextItem);
|
||||
nextItem.querySelector('.item-header a').focus();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function goToNextListItem() {
|
||||
let currentItem = document.querySelector(".current-item");
|
||||
let items = DomHelper.getVisibleElements(".items .item");
|
||||
if (items.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentItem === null) {
|
||||
if (document.querySelector(".current-item") === null) {
|
||||
items[0].classList.add("current-item");
|
||||
items[0].querySelector('.item-header a').focus();
|
||||
return;
|
||||
|
@ -432,12 +436,17 @@ function goToNextListItem() {
|
|||
if (items[i].classList.contains("current-item")) {
|
||||
items[i].classList.remove("current-item");
|
||||
|
||||
let nextItem;
|
||||
if (i + 1 < items.length) {
|
||||
items[i + 1].classList.add("current-item");
|
||||
DomHelper.scrollPageTo(items[i + 1]);
|
||||
items[i + 1].querySelector('.item-header a').focus();
|
||||
nextItem = items[i + 1];
|
||||
} else {
|
||||
nextItem = items[0];
|
||||
}
|
||||
|
||||
nextItem.classList.add("current-item");
|
||||
DomHelper.scrollPageTo(nextItem);
|
||||
nextItem.querySelector('.item-header a').focus();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue