Improve Gallery keyboard navigation

This commit is contained in:
Leo Vasanko 2023-11-18 12:37:48 -08:00
parent 2ff0f78759
commit a366a0bcc6

View File

@ -107,6 +107,10 @@ defineExpose({
const increment = (i: number, d: number) => mod(i + d, N + 1) const increment = (i: number, d: number) => mod(i + d, N + 1)
const index = const index =
store.cursor ? docs.findIndex(doc => doc.key === store.cursor) : N store.cursor ? docs.findIndex(doc => doc.key === store.cursor) : N
// Stop navigation sideways away from the grid (only with up/down)
if (ev && index === 0 && ev.key === "ArrowLeft") return
if (ev && index === N - 1 && ev.key === "ArrowRight") return
// Calculate new position
let moveto let moveto
if (index === N) moveto = d > 0 ? 0 : N - 1 if (index === N) moveto = d > 0 ? 0 : N - 1
else { else {