diff --git a/lib/forcegraph.js b/lib/forcegraph.js index 6189ff9..ba15722 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -124,9 +124,6 @@ define(["d3"], function (d3) { panzoomReal(translate, scale) - - translateP = translate - scaleP = scale } function panzoomReal(translate, scale) { @@ -134,7 +131,7 @@ define(["d3"], function (d3) { right: (canvas.width - translate[0]) / scale, bottom: (canvas.height - translate[1]) / scale} - redraw() + requestAnimationFrame(redraw) } function getSize() { @@ -266,6 +263,10 @@ define(["d3"], function (d3) { xExtent[1] - xExtent[0] + 2 * margin, yExtent[1] - yExtent[0] + 2 * margin) + // Remeber last translate/scale state + translateP = translate + scaleP = scale + ctx.beginPath() nodes.filter(visibleNodes).forEach(function (d) { var clients = d.o.node.statistics.clients @@ -384,7 +385,7 @@ define(["d3"], function (d3) { canvas.style.height = el.offsetHeight + "px" ctx.resetTransform() ctx.scale(r, r) - redraw() + requestAnimationFrame(redraw) } function distance(a, b) {