Skip to content

Commit

Permalink
fix: Ensure color propagation by adding colors before message animation
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Nov 30, 2024
1 parent 2147b6a commit 7802dbc
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions hugo-site/static/html/eventual_convergence_viz.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,21 @@ <h1 class="title">Freenet Eventual Convergence Simulation</h1>
.attr("stroke-width", 0.5);
});

await messageGroup
.transition()
.duration(1000)
.attr("transform", `translate(${target.x},${target.y})`)
.remove()
.end();

// Add only new valid colors to the target node's history
// Add colors to target before animation
validColors.forEach(color => {
if (!target.data.receivedColors.includes(color)) {
target.data.receivedColors.push(color);
}
});

updateNodeColors(target);
await checkAndPropagate(target);

// Then animate the message
await messageGroup
.transition()
.duration(1000)
.attr("transform", `translate(${target.x},${target.y})`)
.remove()
.end();
} finally {
// Clear animation flag when done
animationQueue.delete(animationKey);
Expand Down

0 comments on commit 7802dbc

Please sign in to comment.