projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.46k stars 1.16k forks source link

Fix set position bug #882

Closed vadimshvetsov closed 2 years ago

vadimshvetsov commented 2 years ago

Checklist

What?

At NodeModel and PortModel method setPosition currently doesn't work properly if we pass only Point as a first argument.

Why?

Because NodeModel.setPosition for instance sets position to it's ports with this code:

https://github.com/projectstorm/react-diagrams/blob/dd68d1fe671925ba81d8e9e80ae6b3467e2d5c30/packages/react-diagrams-core/src/entities/node/NodeModel.ts#L42-L52

x can be PointModel and y we could never have, that's why ports never get correct position

How?

We should use this.position.x and this.position.y for getting correct position for ports and points.

Feel good image:

image