feat(dia.Element): add getPortBBox(), getPortCenter(); port metrics caching#2944
Merged
Geliogabalus merged 8 commits intoApr 30, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces new port metric methods for dia.Element, adds caching for port layout calculations, and improves connection points performance by leveraging model geometry. It also updates test cases and examples to reflect these new capabilities.
- Added getPortCenter() and getPortBBox() methods to retrieve port center and bounding box.
- Replaced linear port lookups with constant-time operations and introduced caching.
- Extended connection point functions with a useModelGeometry option for DOM‐independent rendering.
Reviewed Changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/joint-core/test/jointjs/elementPorts.js | Added tests for getPortCenter() and getPortBBox() methods |
| packages/joint-core/test/jointjs/connectionPoints.js | Extended tests with useModelGeometry option for connection points |
| packages/joint-core/src/dia/ports.mjs | Updated caching and port metrics calculations |
| packages/joint-core/src/dia/Element.mjs | Refactored port center logic to use getPortCenter() |
| packages/joint-core/src/connectionPoints/index.mjs | Modified connection point logic to consider model geometry |
| packages/joint-core/src/anchors/index.mjs | Adjusted rotation handling in anchor calculations |
| examples/connection-points-ts/* | Updated configuration and examples to showcase new connection point APIs |
Files not reviewed (3)
- examples/connection-points-ts/.gitignore: Language not supported
- examples/connection-points-ts/package.json: Language not supported
- examples/connection-points-ts/tsconfig.json: Language not supported
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Geliogabalus
approved these changes
Apr 30, 2025
kumilingus
added a commit
that referenced
this pull request
May 3, 2025
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.
feat(dia.Element): Add
getPortBBox()andgetPortCenter()methodsIntroduced methods to retrieve the bounding box and center of a specific port. Includes caching to avoid redundant port layout calculations on repeated calls.
perf(dia.Element): Optimize
hasPort()andhasPorts()methodsImproved performance by leveraging internal data structures for constant-time (O(1)) lookups, replacing the previous linear-time (O(n)) approach.
feat(connectionPoints): Add
useModelGeometryoption tobboxandrectangleconnection pointsEnables calculation of connection points using only the model geometry—ideal for scenarios requiring DOM-independent rendering or performance-sensitive environments.
feat(examples): add
connection-points-tsexample showcasing various connection points scenarios