reagraph icon indicating copy to clipboard operation
reagraph copied to clipboard

Fix graph only centering when nodes out of view

Open ghsteff opened this issue 1 year ago β€’ 1 comments

PR Checklist

Please check if your PR fulfills the following requirements:

  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The graph will only center if a node is out of view, even when trying to center manually from a control button

What is the new behavior?

The graph centers when triggering manually with controls

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

BEFORE

https://github.com/reaviz/reagraph/assets/40581813/469417a7-58c2-41a4-bb30-506a955ae1e1

AFTER

https://github.com/reaviz/reagraph/assets/40581813/19a225e1-62c3-4a2f-a971-a54faca692fe

ghsteff avatar Mar 19 '24 19:03 ghsteff

ideally I would have made a change here like

if (nodes?.some(node => !isNodeInView(camera, node.position)) {
	ref.current?.centerGraph([data.id, ...adjacents]);
}

but you can’t use the useThree hook in here to get the camera object because it's outside of the canvas component, so went with this centerIfNodesNotInView flag argument passed to centerGraph instead

ghsteff avatar Mar 19 '24 19:03 ghsteff

Deploy Preview for reagraph ready!

Name Link
Latest commit 4be6423693732977fbe544eb512e1c766bf63f8c
Latest deploy log https://app.netlify.com/sites/reagraph/deploys/65fd53fcfad69600083dd817
Deploy Preview https://deploy-preview-208--reagraph.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Mar 21 '24 19:03 netlify[bot]