diff --git a/schemius-web/schemius.js b/schemius-web/schemius.js index ee32874..a3f9f70 100644 --- a/schemius-web/schemius.js +++ b/schemius-web/schemius.js @@ -188,19 +188,21 @@ class Schemius { const xDelta = touch.clientX - Schemius.xStart; const yDelta = touch.clientY - Schemius.yStart; - const key = - Math.abs(xDelta) > Math.abs(yDelta) + const [key, timeout] = + Math.abs(xDelta) > 0.5 * Math.abs(yDelta) ? xDelta > 0 - ? "ArrowRight" - : "ArrowLeft" + ? ["ArrowRight", 50] + : ["ArrowLeft", 50] : yDelta > 0 - ? "ArrowDown" - : "ArrowUp"; + ? ["ArrowDown", 100] + : ["ArrowUp", 100]; // Schemius.xStart = null; // Schemius.yStart = null; - Schemius.dispatchKeyEvent(key); + setTimeout(() => { + Schemius.dispatchKeyEvent(key); + }, timeout); return false; } @@ -223,6 +225,10 @@ class Schemius { } } + static toEventSink() { + return false; + } + static handleKeyDown(e) { if (e.ctrlKey) { if (e.key !== "V") { @@ -328,7 +334,8 @@ class Schemius { $(document) .on("touchstart", Schemius.terminal, Schemius.handleTouchStart) - .on("touchmove", Schemius.terminal, Schemius.handleTouchMove); + .on("touchmove", Schemius.terminal, Schemius.handleTouchMove) + .on("touchend", Schemius.terminal, Schemius.toEventSink); // $(window).on("orientationchange", Schemius.setSize); }