From 9ac0f8231cf297f2918135cb020521a13490ccc7 Mon Sep 17 00:00:00 2001 From: Mark Tolmacs Date: Wed, 10 Sep 2025 17:34:19 +0200 Subject: [PATCH] fix:Highlight flicker Signed-off-by: Mark Tolmacs --- packages/element/src/linearElementEditor.ts | 122 ++++++++++---------- 1 file changed, 59 insertions(+), 63 deletions(-) diff --git a/packages/element/src/linearElementEditor.ts b/packages/element/src/linearElementEditor.ts index 0b51a9af0..4a89f21ca 100644 --- a/packages/element/src/linearElementEditor.ts +++ b/packages/element/src/linearElementEditor.ts @@ -335,39 +335,37 @@ export class LinearElementEditor { // Apply the point movement if needed let suggestedBinding: AppState["suggestedBinding"] = null; - if (deltaX || deltaY) { - const { positions, updates } = pointDraggingUpdates( - [idx], - deltaX, - deltaY, - elementsMap, + const { positions, updates } = pointDraggingUpdates( + [idx], + deltaX, + deltaY, + elementsMap, + element, + elements, + app, + ); + + LinearElementEditor.movePoints(element, app.scene, positions, updates); + // Set the suggested binding from the updates if available + if (isBindingElement(element, false)) { + if (isBindingEnabled(app.state)) { + suggestedBinding = updates?.suggestedBinding ?? null; + } + } + + // Move the arrow over the bindable object in terms of z-index + if (isBindingElement(element)) { + moveArrowAboveBindable( + LinearElementEditor.getPointGlobalCoordinates( + element, + element.points[element.points.length - 1], + elementsMap, + ), element, elements, - app, + elementsMap, + app.scene, ); - - LinearElementEditor.movePoints(element, app.scene, positions, updates); - // Set the suggested binding from the updates if available - if (isBindingElement(element, false)) { - if (isBindingEnabled(app.state)) { - suggestedBinding = updates?.suggestedBinding ?? null; - } - } - - // Move the arrow over the bindable object in terms of z-index - if (isBindingElement(element)) { - moveArrowAboveBindable( - LinearElementEditor.getPointGlobalCoordinates( - element, - element.points[element.points.length - 1], - elementsMap, - ), - element, - elements, - elementsMap, - app.scene, - ); - } } // PERF: Avoid state updates if not absolutely necessary @@ -481,42 +479,40 @@ export class LinearElementEditor { // Apply the point movement if needed let suggestedBinding: AppState["suggestedBinding"] = null; - if (deltaX || deltaY) { - const { positions, updates } = pointDraggingUpdates( - selectedPointsIndices, - deltaX, - deltaY, - elementsMap, + const { positions, updates } = pointDraggingUpdates( + selectedPointsIndices, + deltaX, + deltaY, + elementsMap, + element, + elements, + app, + ); + + LinearElementEditor.movePoints(element, app.scene, positions, updates); + + // Set the suggested binding from the updates if available + if (isBindingElement(element, false)) { + if (isBindingEnabled(app.state) && (startIsSelected || endIsSelected)) { + suggestedBinding = updates?.suggestedBinding ?? null; + } + } + + // Move the arrow over the bindable object in terms of z-index + if (isBindingElement(element) && startIsSelected !== endIsSelected) { + moveArrowAboveBindable( + LinearElementEditor.getPointGlobalCoordinates( + element, + startIsSelected + ? element.points[0] + : element.points[element.points.length - 1], + elementsMap, + ), element, elements, - app, + elementsMap, + app.scene, ); - - LinearElementEditor.movePoints(element, app.scene, positions, updates); - - // Set the suggested binding from the updates if available - if (isBindingElement(element, false)) { - if (isBindingEnabled(app.state) && (startIsSelected || endIsSelected)) { - suggestedBinding = updates?.suggestedBinding ?? null; - } - } - - // Move the arrow over the bindable object in terms of z-index - if (isBindingElement(element) && startIsSelected !== endIsSelected) { - moveArrowAboveBindable( - LinearElementEditor.getPointGlobalCoordinates( - element, - startIsSelected - ? element.points[0] - : element.points[element.points.length - 1], - elementsMap, - ), - element, - elements, - elementsMap, - app.scene, - ); - } } // Attached text might need to update if arrow dimensions change