Skip to content

Commit

Permalink
feat(simulation): add option to enable simulation during zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
Stukova committed Jan 24, 2025
1 parent 5e9d71b commit 26d946e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,13 @@ export interface GraphConfigInterface {
* Default: `false`
*/
disableZoom?: boolean;
/**
* Controls whether the simulation remains active during zoom operations.
* When set to `true`, the simulation continues running while zooming.
* When set to `false`, the simulation pauses during zoom operations.
* Default value: `false`
*/
enableSimulationDuringZoom?: boolean;
/**
* Enables or disables dragging of points in the graph.
* Default value: `false`
Expand Down Expand Up @@ -521,6 +528,7 @@ export class GraphConfig implements GraphConfigInterface {
public scalePointsOnZoom = defaultConfigValues.scalePointsOnZoom
public initialZoomLevel = undefined
public disableZoom = defaultConfigValues.disableZoom
public enableSimulationDuringZoom = defaultConfigValues.enableSimulationDuringZoom
public enableDrag = defaultConfigValues.enableDrag
public fitViewOnInit = defaultConfigValues.fitViewOnInit
public fitViewDelay = defaultConfigValues.fitViewDelay
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ export class Graph {
this.forceMouse?.run()
this.points.updatePosition()
}
if ((isSimulationRunning && !this.zoomInstance.isRunning)) {
if ((isSimulationRunning && !(this.zoomInstance.isRunning && !this.config.enableSimulationDuringZoom))) {
if (simulationGravity) {
this.forceGravity?.run()
this.points.updatePosition()
Expand Down
1 change: 1 addition & 0 deletions src/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const defaultConfigValues = {
pixelRatio: 2,
scalePointsOnZoom: true,
disableZoom: false,
enableSimulationDuringZoom: false,
enableDrag: false,
fitViewOnInit: true,
fitViewDelay: 250,
Expand Down

0 comments on commit 26d946e

Please sign in to comment.