diff --git a/src/app.js b/src/app.js index 1f9dd14c276a634468df01cee9c7960abb6534c9..17b53a1b7b4031a795d08d549b29622037f8f1f2 100644 --- a/src/app.js +++ b/src/app.js @@ -387,15 +387,9 @@ HTML.fastUndoButton.addEventListener("click", () => { } }) -HTML.undoButton.addEventListener("mouseup", () => { - clearInterval(undoInterval) -}) - -HTML.undoButton.addEventListener("mouseleave", () => { - clearInterval(undoInterval) -}) +const undoButtonEnd = () => clearInterval(undoInterval) -HTML.undoButton.addEventListener("mousedown", () => { +const undoButtonStart = () => { undoInterval = setInterval(function() { if (room == null) return @@ -406,7 +400,13 @@ HTML.undoButton.addEventListener("mousedown", () => { HTML.undoButton.classList.add("disabled") } }, 1000 / UNDO_RATE) -}) +} + +HTML.undoButton.addEventListener("pointerup", undoButtonEnd) +HTML.undoButton.addEventListener("pointerleave", undoButtonEnd) +HTML.undoButton.addEventListener("mouseup", undoButtonEnd) + +HTML.undoButton.addEventListener("pointerdown", undoButtonStart) HTML.roomIDElem.addEventListener("keydown", (event) => { if (event.key == "Enter") {