From 7ca77cad28b092417430324f667c9d2b0542afb8 Mon Sep 17 00:00:00 2001 From: Yuriy Maksymets <iurii.maksymets@gmail.com> Date: Thu, 2 Jan 2020 19:54:11 +0000 Subject: [PATCH] Pointer events for undo button --- src/app.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app.js b/src/app.js index 1f9dd14..17b53a1 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") { -- GitLab