Skip to content

Commit

Permalink
Added arrow keys in TSV viewer for quick nav.
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Jun 22, 2024
1 parent 7299857 commit c42736d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/tsvView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ let renderImage = function () {
let data = resourceViewer.data(rsrcID.data || resourceViewer.keys()[0]);
canvas.width = data.width * pxSize.data;
canvas.height = data.height * pxSize.data;
console.debug(data);
if (loadType.data == 1) {
canvas.width = canvas.width << 1;
};
Expand Down Expand Up @@ -106,7 +105,7 @@ let loadResource = async () => {
};
rsrcID.appendChild(newChoice);
});
//renderImage();
renderImage();
};
};
$e("#openImage").addEventListener("mouseup", async () => {
Expand All @@ -125,5 +124,24 @@ document.addEventListener("keydown", (ev) => {
renderImage();
break;
};
case "ArrowDown":
case "ArrowRight": {
if (rsrcID.selectedIndex + 1 < rsrcID.options.length) {
rsrcID.selectedIndex ++;
rsrcID.dispatchEvent(new Event("change"));
};
break;
};
case "ArrowUp":
case "ArrowLeft": {
if (rsrcID.selectedIndex > 0) {
rsrcID.selectedIndex --;
rsrcID.dispatchEvent(new Event("change"));
};
break;
};
default: {
console.debug(`Unknown key "${ev.key}".`);
};
};
});

0 comments on commit c42736d

Please sign in to comment.