           d._children = null
 
       # Function to center node when clicked/dropped so node doesn't get lost when collapsing/moving with large amount of children.
-      centerNode = (source)->
+      centerNode = (source)=>
         scale = zoomListener.scale()
         x = -1 * source.y0
         y = -1 * source.x0
-        x = x * scale + viewerWidth / 4
-        y = y * scale + viewerHeight / 2
+        x = x * scale + @viewerWidth / 4
+        y = y * scale + @viewerHeight / 2
         d3.select('g').transition()
-            .duration(duration)
+            .duration(NODE_TRANSITION_DURATION)
             .attr("transform", "translate(" + x + "," + y + ")scale(" + scale + ")")
         zoomListener.scale(scale)
         zoomListener.translate([x, y])

# Within 20px from edges will pan when dragging.
PAN_BOUNDARY = 20



PROTOCOL = "proto-repl-sayid:"

      zoomListener = d3.behavior.zoom().scaleExtent([0.1, 3]).on("zoom", zoom)

      baseSvg = d3.select(@graphDiv).append("svg")
          # .attr("width", @viewerWidth)
          # .attr("height", @viewerHeight)
          .attr("class", "sayid-overlay")
          .call(zoomListener)

