projectstorm / react-diagrams

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

Fix the zoomToFitNodes offsets calculation #875

Closed GaryPan-1515 closed 2 years ago

GaryPan-1515 commented 2 years ago

Checklist

What?

The offset calculation method in the DiagramEngine.zoomToFitNodes has problems. This PR fixes the issue

Before

before

After

after

Why?

How?

The nodes bounding box's coordinates were not scaled by the zoom factor causing this bug

Feel good image:

(Add your own one below :])

LOL

GaryPan-1515 commented 2 years ago

@dylanvorster Would you take a look at this fix? Thanks!

dalex-am commented 2 years ago

@dylanvorster Would you take a look at this fix? Thanks!

I fixed zoomToFit method in my project and got same results with one difference: in the end of offsets I got margin * zoomFactor instead of just margin