Added fix for grid nudge causing scroll

This commit is contained in:
Mitchell McCaffrey 2021-02-07 17:40:22 +11:00
parent 9f96145410
commit 9892227caf

View File

@ -162,9 +162,12 @@ function MapGridEditor({ map, onGridChange }) {
});
}
function handleKeyDown({ key, shiftKey }) {
function handleKeyDown(event) {
const { key, shiftKey } = event;
const nudgeAmount = shiftKey ? 2 : 0.5;
if (key === "ArrowUp") {
// Stop arrow up/down scrolling if overflowing
event.preventDefault();
nudgeGrid({ x: 0, y: -1 }, nudgeAmount);
}
if (key === "ArrowLeft") {
@ -174,6 +177,7 @@ function MapGridEditor({ map, onGridChange }) {
nudgeGrid({ x: 1, y: 0 }, nudgeAmount);
}
if (key === "ArrowDown") {
event.preventDefault();
nudgeGrid({ x: 0, y: 1 }, nudgeAmount);
}
}