diff --git a/lib/forcegraph.js b/lib/forcegraph.js index 5ab78f4..c9ccbdf 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -120,8 +120,6 @@ define(["d3"], function (d3) { } } - var translateP, scaleP - function onPanZoom() { savedPanZoom = {translate: zoomBehavior.translate(), scale: zoomBehavior.scale()} @@ -258,32 +256,15 @@ define(["d3"], function (d3) { var scale = zoomBehavior.scale() var links = intLinks.filter(visibleLinks) - var xExtent = d3.extent(intNodes, function (d) { return d.px }) - var yExtent = d3.extent(intNodes, function (d) { return d.py }) - - if (translateP) { - ctx.save() - ctx.translate(translateP[0], translateP[1]) - ctx.scale(scaleP, scaleP) - ctx.clearRect(xExtent[0] - margin, yExtent[0] - margin, - xExtent[1] - xExtent[0] + 2 * margin, - yExtent[1] - yExtent[0] + 2 * margin) - ctx.restore() - } + ctx.save() + ctx.setTransform(1, 0, 0, 1, 0, 0) + ctx.clearRect(0, 0, canvas.width, canvas.height) + ctx.restore() ctx.save() ctx.translate(translate[0], translate[1]) ctx.scale(scale, scale) - if (!translateP) - ctx.clearRect(xExtent[0] - margin, yExtent[0] - margin, - xExtent[1] - xExtent[0] + 2 * margin, - yExtent[1] - yExtent[0] + 2 * margin) - - // Remeber last translate/scale state - translateP = translate - scaleP = scale - var clientColor = "rgba(230, 50, 75, 1.0)" var unknownColor = "#D10E2A" var nodeColor = "#F2E3C6"