Grid view: arrow up/down moves vertically by column count; left/right moves linearly
This commit is contained in:
@@ -672,6 +672,14 @@ function getFilteredEntries(noFolder) {
|
|||||||
return entries.filter(e => (e.folder || 'All') === selectedFolder);
|
return entries.filter(e => (e.folder || 'All') === selectedFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getGridCols() {
|
||||||
|
const c = document.getElementById('entriesContainer');
|
||||||
|
if (!c || !c.firstElementChild) return 1;
|
||||||
|
const w = c.firstElementChild.offsetWidth;
|
||||||
|
const gap = parseInt(getComputedStyle(c).columnGap) || 0;
|
||||||
|
return Math.max(1, Math.round(c.offsetWidth / (w + gap)));
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== RENDER ====================
|
// ==================== RENDER ====================
|
||||||
function render() {
|
function render() {
|
||||||
const c = document.getElementById('entriesContainer');
|
const c = document.getElementById('entriesContainer');
|
||||||
@@ -1420,8 +1428,13 @@ document.addEventListener('keydown', function(e) {
|
|||||||
const firstId = [...selectedIds][0];
|
const firstId = [...selectedIds][0];
|
||||||
idx = filtered.findIndex(e => e.id == firstId);
|
idx = filtered.findIndex(e => e.id == firstId);
|
||||||
}
|
}
|
||||||
if (isNext) idx = idx < filtered.length - 1 ? idx + 1 : 0;
|
if (view === 'grid' && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
|
||||||
else idx = idx > 0 ? idx - 1 : filtered.length - 1;
|
if (idx < 0) idx = 0;
|
||||||
|
else { const cols = getGridCols(); if (e.key === 'ArrowDown') { const next = idx + cols; idx = next < filtered.length ? next : idx; } else { const prev = idx - cols; idx = prev >= 0 ? prev : idx; } }
|
||||||
|
} else {
|
||||||
|
if (isNext) idx = idx < filtered.length - 1 ? idx + 1 : 0;
|
||||||
|
else idx = idx > 0 ? idx - 1 : filtered.length - 1;
|
||||||
|
}
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
const anchorId = lastSelectedId !== null ? lastSelectedId : filtered[idx].id;
|
const anchorId = lastSelectedId !== null ? lastSelectedId : filtered[idx].id;
|
||||||
const anchor = filtered.findIndex(e => e.id == anchorId);
|
const anchor = filtered.findIndex(e => e.id == anchorId);
|
||||||
|
|||||||
Reference in New Issue
Block a user