Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-pugs-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': patch
---

fix(force-simulation): Fixed a bug that would sometimes keep a simulation running, when its inputs change, even if `alpha < alphaMin`
15 changes: 9 additions & 6 deletions packages/layerchart/src/lib/components/ForceSimulation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,8 @@
// pass it to the internal d3 simulation object:
pushAlphaToSimulation(alpha);

// Only resume the simulation as long as `alpha`
// is above the cut-off threshold of `alphaMin`,
// otherwise our simulation will never terminate:
if (simulation.alpha() >= simulation.alphaMin()) {
runOrResumeSimulation();
}
// Then we attempt to resume the simulation:
runOrResumeSimulation();
}
);

Expand Down Expand Up @@ -404,6 +400,13 @@
return;
}

if (simulation.alpha() < simulation.alphaMin()) {
// Only resume the simulation as long as `alpha`
// is above the cut-off threshold of `alphaMin`,
// otherwise our simulation will never terminate:
return;
}

onStart();
simulation.restart();

Expand Down
Loading