Repository navigation
feat(connectionStrategies): add pin() factory with useModelGeometry and clamp options - #3580
Merged
kumilingus merged 2 commits intoOct 29, 2026
Merged
Conversation
…nd clamp options
Make the private pin() factory public with `relative`, `useModelGeometry`
and `clamp` options. With `useModelGeometry`, the offsets are measured
against the element's (or port's) model bbox - the same box the anchor
resolves them against - instead of the rendered magnet. With `clamp`, a
point outside the element is moved onto its edge.
pinAbsolute and pinRelative are now pin() and pin({ relative: true }).
Closes clientIO#3531
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Geliogabalus
force-pushed
the
feat/connection-strategies-pin
branch
from
October 29, 2026 10:32
c37d0b2 to
29cbf71
Compare
The strategy created by pin() kept a reference to the options object, so modifying it afterwards changed the strategy. Copy the options, with their defaults, when the strategy is created. Document the defaults and the port and link-end behavior in PinOptions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
kumilingus
approved these changes
Oct 29, 2026
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.
Description
Makes the private
pin()factory public, with three options:useModelGeometrymeasureselement.getBBox(), orelement.getPortBBox(port)when the end has a port. It undoes the rotation around that box's center. ThetopLeftanchor withuseModelGeometryandrotate: trueuses the same box and pivot, so the anchor resolves to the dropped point.clamplimits the offsets to[0, width]×[0, height].pinAbsoluteandpinRelativeare nowpin()andpin({ relative: true })and behave as before. The strategy no longer rotates the passedcoordsin place.useModelGeometryandclamp, because the closest point on a connection already lies on it.Fixes #3531
Motivation and Context
pinRelative/pinAbsolutemeasure the rendered node under the pointer. An app whose anchors useuseModelGeometrygets offsets computed for one box and applied to another. WithsnapLinks, an end dropped next to an element is also stored outside it, so it floats beside the element and drifts away when the element is resized. Today an app has to write its own strategy to work around this.Tests
test/jointjs/linkView.jsadds apin()module. It covers the defaults,relative,clamp,useModelGeometryon a label magnet and on a port, and thatcoordsare left unchanged. A round-trip test on a rotated element checks that the anchor resolves back to the dropped point for every combination ofrelativeanduseModelGeometry.test/ts/shapes.test.tsadds a typings check.