From 6e19d60fdecaee0138299de83c3e98644d003877 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 29 Sep 2014 16:34:31 +0300 Subject: rhizicore: fix popping node on top left when creating a new node The fix is ugly. Basically we are relying on the force layout [1] for the locations of the nodes. I've hidden the node until the first tick. Since we do a tick calculation (tick is a function in rhizicore) when adding a node there is no associated delay. [1] https://github.com/mbostock/d3/wiki/Force-Layout --- scripts/rhizicore.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts') diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js index de185fc9..70adfc3b 100644 --- a/scripts/rhizicore.js +++ b/scripts/rhizicore.js @@ -578,6 +578,7 @@ function myGraph(el) { var nodeEnter = node.enter() .append("g").attr('class', 'node') + .attr('visibility', 'hidden') // made visible on first tick .on("click", function(d, i) { if (d3.event.defaultPrevented) { // drag happened, ignore click https://github.com/mbostock/d3/wiki/Drag-Behavior#on @@ -827,6 +828,9 @@ function tick(e) { } }); + // After initial placement we can make the nodes visible. + //links.attr('visibility', 'visible'); + node.attr('visibility', 'visible'); } -- cgit v1.3.1