projectstorm / react-diagrams

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

Linking by clicking instead of dragging is broken when zooming #685

Open jmlevesque333 opened 4 years ago

jmlevesque333 commented 4 years ago

Hello, it appears that clicking instead of dragging is broken when your zooming in or out in the canvas. This can be tested straight on the demo website here In this image I zoomed out a little bit then click on the port to create a link and it broke. image

samuei commented 1 year ago

Confirmed still an issue in 2023. See also #709. There's a lengthy solution proposed there, but I suspect it no longer applies.

I've had limited success with our custom links by multiplying the links' points values by the zoomLevel manually, but I don't know whether that's portable back to the default and it's not solving the problem in all my use cases anyway.

samuei commented 1 year ago

After bashing my head against this for some time, I've found a partial solution that works most of the time for me. We're copying the first/last points' position properties (modifying them directly means the links will jump around with every render), then multiplying each by model.getParentCanvasModel().getZoomLevel() / 100 for proper scaling. This works fine most of the time. Not foolproof, but maybe helpful for folks coming here from Google.