Skip to content

feat(router): add minMargin option to rightAngle router to suppress margin-overlap detours#3266

Open
Geliogabalus wants to merge 19 commits intoclientIO:masterfrom
Geliogabalus:right-angle-fix
Open

feat(router): add minMargin option to rightAngle router to suppress margin-overlap detours#3266
Geliogabalus wants to merge 19 commits intoclientIO:masterfrom
Geliogabalus:right-angle-fix

Conversation

@Geliogabalus
Copy link
Copy Markdown
Contributor

@Geliogabalus Geliogabalus commented Apr 7, 2026

Summary

  • Add a minMargin option to rightAngleRouter (TypeScript type included)
  • Rename internal margin-boundary variables in resolveForTopSourceSide, resolveForBottomSourceSide, resolveForLeftSourceSide, and resolveForRightSourceSide from short (smx0, smy1, …) to descriptive names (sMarginX0, sMarginY1, …) for readability
  • Inside routeBetweenPoints, derive tighter routing boundaries using minMargin:
    • minSourceMargin = Math.min(minMargin, sourceMargin) (falls back to sourceMargin when minMargin is null)
    • sMinMarginX0/X1/Y0/Y1 and tMinMarginX0/X1/Y0/Y1 are used in place of full-margin boundaries in the facing-anchor and overlap routing branches, allowing routes to pass closer to elements when minMargin is set
  • Propagate minMargin to every routeBetweenPoints call site throughout rightAngleRouter
  • Add a right-angle-playground-js example demonstrating the option with movable vertices, anchors, and a resize handle

Test plan

  • Verify the sMinMarginX0/X1 boundaries are respected in the left→right and right→left facing-anchor routing branches when minMargin is set
  • Verify that omitting minMargin (default null) preserves existing routing behaviour in all side combinations
  • Verify the right-angle-playground-js example loads and the router respects the minMargin: 10 setting when elements are dragged close together

🤖 Generated with Claude Code

@Geliogabalus Geliogabalus changed the title fix(router): add ignoreOverlappingMargin support to all routeBetweenPoints combinations fix(dia): correct bounding rect measurement for HTML element magnets Apr 8, 2026
@Geliogabalus Geliogabalus changed the title fix(dia): correct bounding rect measurement for HTML element magnets fix(router): add ignoreOverlappingMargin support to all routeBetweenPoints combinations Apr 8, 2026
@Geliogabalus Geliogabalus changed the title fix(router): add ignoreOverlappingMargin support to all routeBetweenPoints combinations fix(router): add minMargin option to rightAngle router to suppress margin-overlap detours Apr 11, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new minMargin option to the rightAngle router to reduce unnecessary “detour around margin” routes when elements are adjacent and their margin zones only minimally overlap, and introduces a new JS playground example to demonstrate the behavior.

Changes:

  • Add minMargin option to rightAngleRouter and thread it through all routeBetweenPoints calls.
  • Add “ignore overlapping margin” logic in routeBetweenPoints for opposite-side routing cases.
  • Add a new examples/right-angle-playground-js workspace demo (and lockfile entry).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Adds the new @joint/demo-right-angle-playground-js workspace entry.
packages/joint-core/src/routers/rightAngle.mjs Implements minMargin option and new margin-overlap suppression logic.
examples/right-angle-playground-js/src/styles.css Styling for the new playground demo.
examples/right-angle-playground-js/src/main.js Demo setup showcasing rightAngle routing with minMargin.
examples/right-angle-playground-js/package.json Declares the new example workspace package and its scripts/deps.
examples/right-angle-playground-js/index.html HTML entrypoint for the new Vite demo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/joint-core/src/routers/rightAngle.mjs Outdated
Comment thread packages/joint-core/src/routers/rightAngle.mjs
Comment thread packages/joint-core/src/routers/rightAngle.mjs
Comment thread packages/joint-core/src/routers/rightAngle.mjs Outdated
Comment thread packages/joint-core/types/joint.d.ts Outdated
kumilingus
kumilingus previously approved these changes Apr 14, 2026
@kumilingus kumilingus self-requested a review April 14, 2026 10:47
@kumilingus kumilingus dismissed their stale review April 14, 2026 10:48

misclick

@kumilingus kumilingus changed the title fix(router): add minMargin option to rightAngle router to suppress margin-overlap detours feat(router): add minMargin option to rightAngle router to suppress margin-overlap detours Apr 14, 2026
@Geliogabalus Geliogabalus marked this pull request as draft April 15, 2026 08:46
# Conflicts:
#	packages/joint-core/src/routers/rightAngle.mjs
(cherry picked from commit 5192e2d)
@Geliogabalus Geliogabalus marked this pull request as ready for review April 20, 2026 10:03
# Conflicts:
#	packages/joint-core/types/joint.d.ts
# Conflicts:
#	packages/joint-core/src/routers/rightAngle.mjs
#	packages/joint-core/test/jointjs/routers.js
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.

4 participants