Skip to content

Commit

Permalink
fix: Resolve initialization, iteration, and animation frame errors in…
Browse files Browse the repository at this point in the history
… network simulation
  • Loading branch information
sanity committed Nov 27, 2024
1 parent 4adc890 commit e361824
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions hugo-site/static/js/small-world-comparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,12 @@ waitForD3().then(() => {
}
statsSvg.selectAll('*').remove();

// Create SVG with fixed dimensions
// Define dimensions first
const margin = {top: 30, right: 60, bottom: 40, left: 60};
const width = 245 - margin.left - margin.right;
const height = 245 - margin.top - margin.bottom;
const svgWidth = 245;
const svgHeight = 245;
const width = svgWidth - margin.left - margin.right;
const height = svgHeight - margin.top - margin.bottom;

// Clear previous content
if (statsSvg) {
Expand Down
6 changes: 4 additions & 2 deletions hugo-site/static/js/small-world-scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ waitForD3().then(() => {
}

// Use pre-computed adjacency list
const neighbors = adjacencyLists.get(node);
const neighbors = adjacencyLists.get(node) || [];
for (const neighbor of neighbors) {
if (!visited.has(neighbor.index)) {
visited.add(neighbor.index);
Expand Down Expand Up @@ -413,7 +413,9 @@ waitForD3().then(() => {
const btn = document.getElementById('scalePlayPauseBtn');
const icon = btn.querySelector('i');
icon.className = 'fas fa-play';
cancelAnimationFrame(animationFrameId);
if (animationFrame) {
cancelAnimationFrame(animationFrame);
}
}
}

Expand Down

0 comments on commit e361824

Please sign in to comment.