From 1b20ffa334be11e3a078a0b3746958c64fef9035 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Tue, 29 Dec 2020 16:36:33 +0900 Subject: [PATCH] refactor: handlers --- src/main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index b9d6c23..ea6f401 100644 --- a/src/main.ts +++ b/src/main.ts @@ -112,17 +112,17 @@ function main() { root.addEventListener("keydown", handleKeydown); root.addEventListener("touchstart", handleTouchmove, { passive: false }); root.addEventListener("touchmove", handleTouchmove, { passive: false }); - root.addEventListener("keyup", handleMouseMoveEnd); - root.addEventListener("touchend", handleMouseMoveEnd); root.addEventListener("mousedown", () => { root.addEventListener("mousemove", handleMouseMove); }); for (const event of ["mouseup", "mouseleave"] as const) { root.addEventListener(event, () => { root.removeEventListener("mousemove", handleMouseMove); - handleMouseMoveEnd(); }); } + for (const event of ["keyup", "mouseup", "mouseleave", "touchend"] as const) { + root.addEventListener(event, handleMouseMoveEnd); + } root.appendChild(canvas); Object.assign(root.style, { overflow: "hidden", overscrollBehavior: "none" }); window.addEventListener("resize", adjustCanvasSize);