refactor: arrow geometry as data (fix head rotation + binding drift) - #114
Open
Amark19 wants to merge 2 commits into
Open
refactor: arrow geometry as data (fix head rotation + binding drift)#114Amark19 wants to merge 2 commits into
Amark19 wants to merge 2 commits into
Conversation
…d-back loop) Adopt the Excalidraw-style idea (on fabric, same group): an arrow's two logical endpoints are now STORED DATA (arrowPoints, group-local), and the rendered children (connector, head(s), label) are derived from that every layout. Before, "where does the arrow point?" was answered by reading the head's own left/top/angle back out (headTipOf). That coupled the truth to the render — a stale head produced a wrong endpoint, which produced a wronger head next re-route: a feedback loop that showed up as "the arrowhead stops rotating" and "bindings drift/get messed up". Decoupling the truth from the render breaks it. - arrowEndpoints.js: ARROW_GEOM_FIELD stores [tail, tip]; applyEndpointsLocal writes it before deriving; refitArrowBounds re-bases it across the frame change; localEndpoints reads it (with one-time reconstruct-from-children migration for old boards/undo snapshots). - binding.js: persist arrowPoints so geometry survives reload/undo. - tests: lock the invariant — a corrupted head no longer moves the endpoint; geometry persists; old arrows migrate. Verified live: straight + elbow heads rotate correctly; endpoints stay glued; 0px drift over 25 re-routes and across refit (no reselect jump). 97 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deploying whiteboard with
|
| Latest commit: |
46f3313
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://53897cbf.whiteboard-988.pages.dev |
| Branch Preview URL: | https://refactor-arrow-data-model.whiteboard-988.pages.dev |
Comments should be short and only where the code can't explain itself; add the convention to AGENTS.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Arrows now store their two logical endpoints as data (
arrowPoints, group-local); the rendered children (connector, head(s), label) are derived from that on every layout — the Excalidraw data-model idea, on the same fabric group.arrowEndpoints.js—ARROW_GEOM_FIELDis the source of truth;applyEndpointsLocalwrites it before deriving;refitArrowBoundsre-bases it across the frame change;localEndpointsreads it (one-time reconstruct-from-children migration for old boards/undo).binding.js— persistarrowPointsso geometry survives reload/undo.Why
"Where does the arrow point?" used to be answered by reading the head's own
left/top/angleback out. That coupled truth to render: a stale head → wrong endpoint → wronger head next re-route. That feedback loop was "the arrowhead stops rotating" and "bindings get messed up". Storing endpoints as data breaks the loop.Test plan
toObject; old arrows migrate.Stacks on #113 (elbow routing) — base is
fix/elbow-smart-and-filters.🤖 Generated with Claude Code