Skip to content

Conversation

@ritk20
Copy link
Contributor

@ritk20 ritk20 commented Oct 3, 2024

Arrow updates on both sides when moving connected objects (issue: #8475)

However, when a smaller shape is inside a bigger one, the updates are too rapid and may not be desirable.

@vercel
Copy link

vercel bot commented Oct 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
excalidraw ✅ Ready (Inspect) Visit Preview Mar 4, 2025 4:22pm
excalidraw-package-example ✅ Ready (Inspect) Visit Preview Mar 4, 2025 4:22pm
excalidraw-package-example-with-nextjs ✅ Ready (Inspect) Visit Preview Mar 4, 2025 4:22pm
1 Skipped Deployment
Name Status Preview Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Mar 4, 2025 4:22pm

@mtolmacs
Copy link
Collaborator

Looks good, but if we fix the situation when both sides of an arrow is bound, we should look into fixing the case when only one side of the arrow is bound to remain consistent:
arrowupdate

@ritk20
Copy link
Contributor Author

ritk20 commented Oct 23, 2024

makes sense, let me try that as well!

@ritk20
Copy link
Contributor Author

ritk20 commented Oct 25, 2024

I am facing some difficulties in arrow movement, specifically how the arrow handles transforming. Specifically, when the transformElements(...) function is called from packages/excalidraw/element/resizeElements.ts, I am able to get the desired behavior in arrow handling using the below code in updateBoundElements(...) function of binding.ts.

if (isBindingElement(changedElement)) {
    if (changedElement.startBinding) {
      const element = elementsMap.get(changedElement.startBinding.elementId);
      if (element) {
        updateBoundElements(element, elementsMap, options);
      }
    }
    if (changedElement.endBinding) {
      const element = elementsMap.get(changedElement.endBinding.elementId);
      if (element) {
        updateBoundElements(element, elementsMap, options);
      }
    }
  }

However, many times when moving the arrowend, the transformElements(...) function is not called rather the handlePointDragging(...) function is called from packages/excalidraw/element/linearElementEditor.ts, which doesnot call the updateBoundElements(...) function, and thus there is no update in the bounded side of the arrow.

@mtolmacs
Copy link
Collaborator

Yes, most likely binding update needs to be called when the handles are dragged, if the arrow is connected on the other end.

@ritk20
Copy link
Contributor Author

ritk20 commented Oct 25, 2024

Works fine

Screen.Recording.2024-10-25.192110.mp4

@mtolmacs
Copy link
Collaborator

...except now you can't unbind a bound arrow @ritk20 :)
unbind

@mtolmacs mtolmacs removed their request for review March 4, 2025 16:17
@mtolmacs
Copy link
Collaborator

mtolmacs commented Mar 4, 2025

Sorry for taking so, so long again, merged! Thanks for your contribution @ritk20!

Jauhen pushed a commit to Jauhen/excalidraw that referenced this pull request Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arrow does not update both sides when moving connected object

3 participants