Use mouse position when undo/redo/reset

This commit is contained in:
Hans5958 2022-05-06 14:26:29 +07:00
parent 4c07c5372d
commit 08f195eb12

View file

@ -169,7 +169,7 @@ function initDraw() {
if (!dragging && drawing && path.length > 0) {
const coords = getCanvasCoords(e.clientX, e.clientY);
render(path.concat([coords]));
render([...path, coords]);
}
});
@ -204,16 +204,22 @@ function initDraw() {
finish();
});
undoButton.addEventListener("click", function() {
undoButton.addEventListener("click", function(e) {
undo();
const coords = getCanvasCoords(e.clientX, e.clientY);
render([...path, coords]);
});
redoButton.addEventListener("click", function() {
redoButton.addEventListener("click", function(e) {
redo();
const coords = getCanvasCoords(e.clientX, e.clientY);
render([...path, coords]);
});
resetButton.addEventListener("click", function() {
resetButton.addEventListener("click", function(e) {
reset();
const coords = getCanvasCoords(e.clientX, e.clientY);
render([...path, coords]);
});
resetButton.addEventListener("blur", function() {