-
Notifications
You must be signed in to change notification settings - Fork 866
feat(dia.Element): add getPortBBox(), getPortCenter(); port metrics c… #2944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dia.Element): add getPortBBox(), getPortCenter(); port metrics c… #2944
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
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
useModelGeometry
option tobbox
andrectangle
connection 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-ts
example showcasing various connection points scenarios