swimlane / ngx-graph

Graph visualization library for angular
https://swimlane.github.io/ngx-graph
MIT License
922 stars 285 forks source link

Fix: Rendering Issues #544

Closed steveblue closed 4 months ago

steveblue commented 4 months ago

What kind of change does this PR introduce? (check one with "x")

What is the current behavior? (You can also link to an open issue here)

  1. User has no way to accurately detect state of the graph on load. Suppose the use case where the user wants to zoom to fit and center on load. This depends on the graph having accurate dimensions, all the nodes having accurate dimensions, but there is no way to tell. This PR adds several outward facing methods to detect if elements have dimension. In addition, a new @Output named stateChanges allows users to listen for changes to the graph. Combined with the being able to check dimensions, a user should now be able to call zoomToFit accurately.
  2. zoomToFit results in two updates to the transform, introducing a flicker when combined with calls to center(). A new optional ZoomOptions can be used to call next() on zoomToFit$ with the option autoCenter, reducing the need to call a second time and introducing a flicker. autoCenter also defers updating the transform on panTo.
  3. Sometimes zoomToFit$ fails because of an internal check of the zoom value and nothing happens except the graph flickers in place. A new ZoomOption named force allows users to bypass the check and zoom to fit anyways.
  4. subscriptions is deprecated in favor of listening for a destroy$ Subject. This matches other Component style.
  5. New enablePreUpdateTransform @Input allows users to disable an update to the transform that happens before another update, reducing the chance of a flicker.

Does this PR introduce a breaking change? (check one with "x")

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information: