Fix touch direction input

This commit is contained in:
Pieter Vander Vennet 2020-11-15 14:12:31 +01:00
parent 4737a6f56c
commit e2881840da
2 changed files with 10 additions and 2 deletions

View file

@ -62,7 +62,9 @@ export default class DirectionInput extends InputElement<string> {
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;

View file

@ -5,10 +5,16 @@ 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")
UIEventSource.Chronic(25, () => {
const degr = (Number(d.data) + 1) % 360;
d.setData(""+ degr);
return true;
})
/*/