-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fix graph only centering when nodes out of view #208
Conversation
ideally I would have made a change here like
but you can’t use the |
src/GraphScene.tsx
Outdated
@@ -233,7 +233,7 @@ export interface GraphSceneRef { | |||
/** | |||
* Center the graph on a node or list of nodes. | |||
*/ | |||
centerGraph: (ids?: string[]) => void; | |||
centerGraph: (ids?: string[], centerIfNodesNotInView?: boolean) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need ot add some docs to this new arg.
✅ Deploy Preview for reagraph ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
src/GraphCanvas.tsx
Outdated
@@ -120,7 +121,14 @@ export const GraphCanvas: FC<GraphCanvasProps & { ref?: Ref<GraphCanvasRef> }> = | |||
const canvasRef = useRef<HTMLCanvasElement | null>(null); | |||
|
|||
useImperativeHandle(ref, () => ({ | |||
centerGraph: (n?: string[]) => rendererRef.current?.centerGraph(n), | |||
centerGraph: ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably would have made nodes the first arg and then all the others a options arg. This makes it a non-breaking change.
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 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?
Other information
BEFORE
Screen.Recording.2024-03-19.at.12.05.28.PM.mov
AFTER
Screen.Recording.2024-03-19.at.12.04.49.PM.mov