From df109d3c8b33d9cfa93239b6ef306fd42df40f17 Mon Sep 17 00:00:00 2001 From: franmagn Date: Thu, 30 Oct 2025 13:03:32 +0100 Subject: [PATCH] refactor(#47): :zap: improve updating of labels on the UI made labels come up faster after a movement, not requiring a camera update anymore --- src/MeasurementControl/measurementsPanel.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/MeasurementControl/measurementsPanel.js b/src/MeasurementControl/measurementsPanel.js index e8766bd..16e4152 100644 --- a/src/MeasurementControl/measurementsPanel.js +++ b/src/MeasurementControl/measurementsPanel.js @@ -862,6 +862,24 @@ export function initMeasurementsPanel(viewer) { }) } catch (_e) {} }) + + // Listen to movement events separately so we can update overlay label + // positions immediately when a marker/point is moved + ;['marker_moved', 'marker_dropped', 'point_moved'].forEach((ev) => { + try { + obj.addEventListener(ev, () => { + // schedule a position update on next frame + requestAnimationFrame(() => updateOverlayPositions()) + // If this measurement is currently selected, refresh the panel too + if (lastSelection.uuid === obj.uuid) { + try { + updateActiveSelection(obj.uuid) + showPanelInMeasurements() + } catch (_e) {} + } + }) + } catch (_e) {} + }) } // Distance/Height/Angle measurements can change type based on point count