Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera is reset when graph is updated #48

Closed
jacomyal opened this issue Mar 22, 2023 · 0 comments
Closed

Camera is reset when graph is updated #48

jacomyal opened this issue Mar 22, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@jacomyal
Copy link
Collaborator

When a new graph prop value is given to some SigmaContainer instance, the camera is reset. I was expecting the camera to remain the same.

The reason is visible here:

if (containerRef.current !== null) {
const sigGraph = graph ? (typeof graph === "function" ? new graph() : graph) : new Graph();
instance = new Sigma(sigGraph, containerRef.current, { allowInvalidContainer: true, ...sigmaSettings.current });
}
setSigma(instance);

The fix would be to copy the camera state if an instance exists already, and set it to the new instance's camera right after it's created. Something like:

const cameraState = instance ? instance.getCamera().getState() : null;

// [...] existing code that remounts the instance

if (cameraState) instance.getCamera().setState(cameraState);
@jacomyal jacomyal added the bug Something isn't working label Mar 22, 2023
jacomyal added a commit to gephi/gephi-lite that referenced this issue Mar 22, 2023
Details:
- Positions are no more always rescaled to fit in the screen at default
camera (this is done using some Sigma#setCustomBBox magic)
- Nodes and edges sizes are now always in the same coordinates system as
the nodes positions (thanks to sigma-3.0.0alpha3)
- SigmaGraph is not fully respawned when its dependencies are updated,
the instance is preserved instead (because of
sim51/react-sigma#48)
@sim51 sim51 closed this as completed in 0c153dd Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant