From c41690aab35e310acd62d163ea6ce579d65bfed4 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 18 Jun 2021 14:30:49 +0200 Subject: [PATCH] Formatting --- UI/BigComponents/Basemap.ts | 9 +++++---- UI/Input/DirectionInput.ts | 35 +++++++++++++++++------------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/UI/BigComponents/Basemap.ts b/UI/BigComponents/Basemap.ts index d2b703658..5c2844bd0 100644 --- a/UI/BigComponents/Basemap.ts +++ b/UI/BigComponents/Basemap.ts @@ -12,13 +12,14 @@ export class Basemap { constructor(leafletElementId: string, location: UIEventSource, currentLayer: UIEventSource, - lastClickLocation: UIEventSource<{ lat: number, lon: number }>, - extraAttribution: BaseUIElement) { + lastClickLocation?: UIEventSource<{ lat: number, lon: number }>, + extraAttribution?: BaseUIElement) { this.map = L.map(leafletElementId, { center: [location.data.lat ?? 0, location.data.lon ?? 0], zoom: location.data.zoom ?? 2, layers: [currentLayer.data.layer], zoomControl: false, + attributionControl: extraAttribution !== undefined }); L.control.scale( @@ -70,12 +71,12 @@ export class Basemap { this.map.on("click", function (e) { // @ts-ignore - lastClickLocation.setData({lat: e.latlng.lat, lon: e.latlng.lng}) + lastClickLocation?.setData({lat: e.latlng.lat, lon: e.latlng.lng}) }); this.map.on("contextmenu", function (e) { // @ts-ignore - lastClickLocation.setData({lat: e.latlng.lat, lon: e.latlng.lng}); + lastClickLocation?.setData({lat: e.latlng.lat, lon: e.latlng.lng}); }); diff --git a/UI/Input/DirectionInput.ts b/UI/Input/DirectionInput.ts index f5b1b05ef..4be40b99e 100644 --- a/UI/Input/DirectionInput.ts +++ b/UI/Input/DirectionInput.ts @@ -10,20 +10,28 @@ import {FixedUiElement} from "../Base/FixedUiElement"; */ export default class DirectionInput extends InputElement { - private readonly value: UIEventSource; public readonly IsSelected: UIEventSource = new UIEventSource(false); + private readonly value: UIEventSource; constructor(value?: UIEventSource) { super(); this.value = value ?? new UIEventSource(undefined); } - + + GetValue(): UIEventSource { + return this.value; + } + + IsValid(str: string): boolean { + const t = Number(str); + return !isNaN(t) && t >= 0 && t <= 360; + } protected InnerConstructElement(): HTMLElement { - const element = new Combine([ + const element = new Combine([ new FixedUiElement("").SetClass("w-full h-full absolute top-0 left-O rounded-full"), Svg.direction_svg().SetStyle( `position: absolute;top: 0;left: 0;width: 100%;height: 100%;transform:rotate(${this.value.data ?? 0}deg);`) @@ -40,18 +48,12 @@ export default class DirectionInput extends InputElement { cone.style.transform = `rotate(${rotation}deg)`; }) - + this.RegisterTriggers(element) - + return element; } - - GetValue(): UIEventSource { - return this.value; - } - - private RegisterTriggers(htmlElement: HTMLElement) { const self = this; @@ -83,19 +85,16 @@ export default class DirectionInput extends InputElement { } htmlElement.onmouseup = (ev) => { - isDown = false; ev.preventDefault(); + isDown = false; + ev.preventDefault(); } htmlElement.onmousemove = (ev: MouseEvent) => { if (isDown) { onPosChange(ev.clientX, ev.clientY); - } ev.preventDefault(); + } + ev.preventDefault(); } } - IsValid(str: string): boolean { - const t = Number(str); - return !isNaN(t) && t >= 0 && t <= 360; - } - } \ No newline at end of file