Skip to content

feat(dia.Element): add getPortBBox(), getPortCenter(); port metrics caching#2944

Merged
Geliogabalus merged 8 commits into
clientIO:masterfrom
kumilingus:connection-points-use-model-geometry
Apr 30, 2025
Merged

feat(dia.Element): add getPortBBox(), getPortCenter(); port metrics caching#2944
Geliogabalus merged 8 commits into
clientIO:masterfrom
kumilingus:connection-points-use-model-geometry

Conversation

@kumilingus

@kumilingus kumilingus commented Apr 28, 2025

Copy link
Copy Markdown
Contributor
  • 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

Copilot AI left a comment

Copy link
Copy Markdown

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

Comment thread packages/joint-core/test/jointjs/elementPorts.js Outdated
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
@zbynekstara zbynekstara changed the title feat(dia.Element): add getPortBBox(), getPortCenter(); port metrics c… feat(dia.Element): add getPortBBox(), getPortCenter(); port metrics caching Aug 15, 2025
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.

3 participants