updatePositions = {
console.log("updatePositions")
forces;
let noop = true
for (const d of nodes) {
const x = xAnchor(d)
const y = yAnchor(d)
if (noop &&
(d.xAnchor !== x || (d.fx !== undefined && d.fx !== x) ||
(d.yAnchor !== y || (d.fy !== undefined && d.fy !== y)))) {
noop = false
}
d.xAnchor = x
if (d.x == null || isNaN(d.x)) {
d.x = x
}
d.yAnchor = y
if (d.y == null || isNaN(d.y)) {
d.y = y
}
}
if (noop && simulation.alpha() == simulation.alphaTarget()) {
console.log("returning early!!!")
console.log({
noop,
alpha: simulation.alpha(),
alphaTarget: simulation.alphaTarget(),
atTarget: simulation.alpha() == simulation.alphaTarget()
})
return
}
refreshForces()
refreshPolygons(nodes)
simulation
.nodes(nodes)
;
const linkForce = simulation.force('link')
linkForce && linkForce.links(links)
simulation.on("tick", () => {
refreshPolygons(nodes)
viewof positions.value = nodes
})
invalidation.then(() => {
simulation.on("tick", null)
})
simulation
.alpha(initialAlphaTarget)
.alphaTarget(0)
.restart()
viewof positions.value = nodes
}