Skip to content

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

Merged

Conversation

kumilingus
Copy link
Contributor

@kumilingus kumilingus commented Apr 28, 2025

  • feat(dia.Element): Add getPortBBox() and getPortCenter() methods
    Introduced 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() and hasPorts() methods
    Improved 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 to bbox and rectangle connection points
    Enables 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

@kumilingus kumilingus marked this pull request as ready for review April 29, 2025 10:03
@kumilingus kumilingus requested a review from Copilot April 29, 2025 10:04
Copy link

@Copilot 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

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

kumilingus and others added 2 commits April 29, 2025 18:05
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kumilingus kumilingus requested a review from Geliogabalus April 29, 2025 10:08
@Geliogabalus Geliogabalus merged commit 4144847 into clientIO:master Apr 30, 2025
3 checks passed
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.

2 participants