Skip to content

Commit 1c46e15

Browse files
eijawernernoahmay
authored andcommitted
bugfix incorrectly zooms when changing style of graph
1 parent 51c47d4 commit 1c46e15

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/neo4j-arc/graph-visualization/GraphVisualizer/Graph/Graph.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class Graph extends React.Component<GraphProps, GraphState> {
162162
}
163163
if (autocompleteRelationships) {
164164
getAutoCompleteCallback((internalRelationships: BasicRelationship[]) => {
165-
this.visualization?.init()
165+
this.visualization?.init(true)
166166
graph.addInternalRelationships(
167167
mapRelationships(internalRelationships, graph)
168168
)
@@ -176,7 +176,7 @@ export class Graph extends React.Component<GraphProps, GraphState> {
176176
graphEventHandler.onItemMouseOut()
177177
})
178178
} else {
179-
this.visualization?.init()
179+
this.visualization?.init(true)
180180
this.visualization?.precomputeAndStart()
181181
}
182182
if (assignVisElement) {
@@ -195,7 +195,7 @@ export class Graph extends React.Component<GraphProps, GraphState> {
195195
}
196196

197197
if (this.props.styleVersion !== prevProps.styleVersion) {
198-
this.visualization?.init()
198+
this.visualization?.init(false)
199199
}
200200
}
201201

src/neo4j-arc/graph-visualization/GraphVisualizer/Graph/visualization/Visualization.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export class Visualization {
321321
callbacksForEvent.forEach(callback => callback.apply(null, args))
322322
}
323323

324-
init(): void {
324+
init(zoomToInitialLevel?: boolean): void {
325325
this.container
326326
.selectAll('g.layer')
327327
.data(['relationships', 'nodes'])
@@ -332,7 +332,9 @@ export class Visualization {
332332
this.updateRelationships()
333333

334334
this.adjustZoomMinScaleExtentToFitGraph()
335-
this.setInitialZoom()
335+
if (zoomToInitialLevel) {
336+
this.setInitialZoom()
337+
}
336338
}
337339

338340
setInitialZoom(): void {

0 commit comments

Comments
 (0)