Fix camera view resetting on label visibility change #215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The camera resets while zooming in on a big graph when label visibility switches
The camera also resets while dragging nodes when other nodes are out view.
Issue Number: #213 #214
What is the new behavior?
The camera doesn't re-center automatically when nodes/labels update. Centering the camera is now left to be handled on a case-by-case basis using the
centerGraph
method fromGraphCanvasRef
Does this PR introduce a breaking change?
Other information
The
node.labelVisible
field was triggering a re-render when it updated that would cause the camera to re-center if any nodes were out of view. Same thing was happening when dragging a node which updatesnode.position
BEFORE
Screen.Recording.2024-04-03.at.12.55.48.PM.mov
AFTER
Screen.Recording.2024-04-03.at.12.54.28.PM.mov