From e2881840da6c439c44adf2025cec1f42a9232add Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 15 Nov 2020 14:12:31 +0100 Subject: [PATCH] Fix touch direction input --- UI/Input/DirectionInput.ts | 2 ++ test.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/UI/Input/DirectionInput.ts b/UI/Input/DirectionInput.ts index 3d7f89a408..d6399fd911 100644 --- a/UI/Input/DirectionInput.ts +++ b/UI/Input/DirectionInput.ts @@ -62,7 +62,9 @@ export default class DirectionInput extends InputElement { htmlElement.ontouchmove = (ev: TouchEvent) => { + console.log("Getting a touch", ev.touches[0].clientX, ev.touches[0].clientY) onPosChange(ev.touches[0].clientX, ev.touches[0].clientY); + ev.preventDefault(); } let isDown = false; diff --git a/test.ts b/test.ts index e578eb8f1f..87cb971bd6 100644 --- a/test.ts +++ b/test.ts @@ -5,9 +5,15 @@ import Direction from "./UI/Input/DirectionInput"; import {UIEventSource} from "./Logic/UIEventSource"; import {VariableUiElement} from "./UI/Base/VariableUIElement"; -const d = new UIEventSource(90); +const d = new UIEventSource("90"); new Direction(d).AttachTo("maindiv") -new VariableUiElement(d.map(d => ""+d+"°")).AttachTo("extradiv") +new VariableUiElement(d.map(d => "" + d + "°")).AttachTo("extradiv") + +UIEventSource.Chronic(25, () => { + const degr = (Number(d.data) + 1) % 360; + d.setData(""+ degr); + return true; +}) /*/