From eb29cdc585a5941a2931b1d40a66196f792ae429 Mon Sep 17 00:00:00 2001 From: ThePetrovich Date: Fri, 27 Jun 2025 19:58:50 +0800 Subject: [PATCH] Prevent propagation on panel --- src/routes/ControlPanel.svelte | 357 +++++++++++++++++--------------- src/routes/predict/+page.svelte | 9 +- 2 files changed, 194 insertions(+), 172 deletions(-) diff --git a/src/routes/ControlPanel.svelte b/src/routes/ControlPanel.svelte index c9b9858..3081dda 100644 --- a/src/routes/ControlPanel.svelte +++ b/src/routes/ControlPanel.svelte @@ -14,12 +14,14 @@ import { getForecast } from "$lib/prediction"; import type { FlightParameters, ProfileName } from "$lib/types"; import { PROFILE_MAP } from "$lib/types"; - import { FlightParametersStore, writeLocalStorage } from '$lib/stores'; + import { FlightParametersStore, writeLocalStorage } from "$lib/stores"; let isCollapsed = false; let selectedProfile: ProfileName = "Normal"; let startPoint = "Custom"; + export let element: HTMLDivElement | null = null; + const now = new Date(); let startDate = now.toISOString().split("T")[0]; // YYYY-MM-DD let startTime = now.toISOString().split("T")[1].split(".")[0]; // HH:MM:SS @@ -27,7 +29,10 @@ let inputLat = $FlightParametersStore.launch_latitude.toString(); let inputLng = $FlightParametersStore.launch_longitude.toString(); - $: $FlightParametersStore.profile = PROFILE_MAP[selectedProfile]; + $: $FlightParametersStore = { + ...$FlightParametersStore, + profile: PROFILE_MAP[selectedProfile], + }; const handleGetPrediction = async () => { console.log("Fetching prediction with parameters:", $FlightParametersStore); @@ -55,7 +60,11 @@ if (!isNaN(lat) && !isNaN(lng)) { $FlightParametersStore.launch_latitude = lat; $FlightParametersStore.launch_longitude = lng; - console.log("Updated position:", $FlightParametersStore.launch_latitude, $FlightParametersStore.launch_longitude); + console.log( + "Updated position:", + $FlightParametersStore.launch_latitude, + $FlightParametersStore.launch_longitude, + ); } else { console.error("Invalid coordinate input"); // TODO: Show a validation error to the user. @@ -74,198 +83,206 @@ inputLat = lat.toString(); inputLng = lng.toString(); }; + + export const getElement = () => { + return element; + }; - - - - - - {#if !isCollapsed} - - - - - - {#each Object.keys(PROFILE_MAP) as profileName} - - {/each} - - - - - - - - - - - - - - - - + {:else} + + + + {/if} + + + + {#if !isCollapsed} + + + + + + {#each Object.keys(PROFILE_MAP) as profileName} + + {/each} + + + + - - - - - / - - + + + + + + + + + + + + + + + + / + + + + + + + - - - - - - - - - - - - -
- - - - - - - -
-
- - + + - - + +
+ + + + + + + + +
+ +
+ + + + + + + + +
+ + + -
- - - - - -
- - - -
-
- {/if} -
+
+ + + +
+ + {/if} + + diff --git a/src/routes/predict/+page.svelte b/src/routes/predict/+page.svelte index 6af1fe0..7a1f701 100644 --- a/src/routes/predict/+page.svelte +++ b/src/routes/predict/+page.svelte @@ -17,9 +17,14 @@ map?.clearMapLayers(); } }); + console.log('ControlPanel mounted'); + console.log(panel); - L.DomEvent.disableClickPropagation(panel?.$element); - L.DomEvent.disableScrollPropagation(panel?.$element); + if (panel) { + let element = panel.getElement(); + L.DomEvent.disableClickPropagation(element); + L.DomEvent.disableScrollPropagation(element); + } });