From dcd72a1268d6d4dc4a01bc4aa6365d7122fe6fb8 Mon Sep 17 00:00:00 2001 From: Johannes Baumeister Date: Mon, 6 Jul 2026 13:50:31 +0200 Subject: [PATCH] Fix rotation handle drag issue and optimize performance --- app.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 74b8e9c..247a623 100644 --- a/app.js +++ b/app.js @@ -566,11 +566,9 @@ document.addEventListener('DOMContentLoaded', async () => { const centerUtm = proj4(wgs84, utm32, [turbine.latlng.lng, turbine.latlng.lat]); const handleUtm = proj4(wgs84, utm32, [handlePos.lng, handlePos.lat]); - // Calculate angle: Math.atan2(dx, dy). Note: y is North (up), x is East (right) - // We want 0 deg to be South (down), following the KSF pattern if needed. - // Moving handle CW (to West/-X) should increase angle. + // Calculate angle const dx = handleUtm[0] - centerUtm[0]; - const dy = centerUtm[1] - handleUtm[1]; // Handle is South of center -> positive dy + const dy = centerUtm[1] - handleUtm[1]; let angle = Math.atan2(-dx, dy) * (180 / Math.PI); if (angle < 0) angle += 360; @@ -579,16 +577,19 @@ document.addEventListener('DOMContentLoaded', async () => { if (activeTurbine?.id === turbine.id) { editKsfAngle.value = angle.toFixed(1); } + }); + turbine.layers.rotationHandle.on('dragend', (e) => { + // Nach dem Drehen alle Geometrien aktualisieren und Handle auf Kreisbahn einrasten lassen const newGeoms = calculateGeometries(turbine.latlng, turbine.rd, turbine.hh, turbine.fr, turbine.ksfAngle, turbine.ksfMirrored, turbine.hersteller); turbine.layers.ksf.clearLayers().addData(newGeoms.ksf); turbine.layers.blf.clearLayers().addData(newGeoms.blf); turbine.layers.mf.clearLayers().addData(newGeoms.mf); + updateRotationHandlePos(turbine); + triggerAutoSave(); }); - turbine.layers.rotationHandle.on('dragend', triggerAutoSave); - turbine.layers.marker.on('add', function() { if (!state.isEditMode && this.dragging) this.dragging.disable(); });