From 662b752a394b8ee890cfe11304c5971cf34ba3ba Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 22 Jul 2020 12:17:06 +0200 Subject: [PATCH] Fix layer toggling --- UI/Base/CheckBox.ts | 6 +++--- UI/UIElement.ts | 6 +++++- index.html | 5 +---- index.ts | 7 +------ 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/UI/Base/CheckBox.ts b/UI/Base/CheckBox.ts index 34c568b..c912425 100644 --- a/UI/Base/CheckBox.ts +++ b/UI/Base/CheckBox.ts @@ -12,14 +12,14 @@ export class CheckBox extends UIElement{ private readonly _showDisabled: string|UIElement; constructor(showEnabled: string|UIElement, showDisabled: string|UIElement, data: UIEventSource = undefined) { - super(data); - this._data = data??new UIEventSource(false); + super(undefined); + this._data = data ?? new UIEventSource(false); + this.ListenTo(this._data); this._showEnabled = showEnabled; this._showDisabled = showDisabled; const self = this; this.onClick(() => { self._data.setData(!self._data.data); - }) } diff --git a/UI/UIElement.ts b/UI/UIElement.ts index a060e27..f32b6e5 100644 --- a/UI/UIElement.ts +++ b/UI/UIElement.ts @@ -53,8 +53,12 @@ export abstract class UIElement { if (this._onClick !== undefined) { const self = this; - element.onclick = () => { + element.onclick = (e) => { + if(e.consumed){ + return; + } self._onClick(); + e.consumed = true; } element.style.pointerEvents = "all"; element.style.cursor = "pointer"; diff --git a/index.html b/index.html index 328fddc..8644f8c 100644 --- a/index.html +++ b/index.html @@ -53,10 +53,7 @@ -
-

Maplayers

-
-
+
diff --git a/index.ts b/index.ts index f6dcf70..ed8f1d2 100644 --- a/index.ts +++ b/index.ts @@ -316,9 +316,4 @@ locationControl.ping(); new CheckBox(new LayerSelection(flayers), `Click here`).AttachTo("filter__selection") - -// --------------- Setting up toggle button for filter ui -------- - -document.querySelector(`#filter__button`).addEventListener(`click`, e => { - document.querySelector(`#filter__popup`).classList.toggle(`filter__popup--show`) -}); + \ No newline at end of file