 
   setOffsetY: (offset) ->
     @viewport.offsety = if offset < 0 then 0 else offset
-    @container.attr 'transform', @getContainerTransform()
+    if @container
+      @container.attr 'transform', @getContainerTransform()
 
    getContainerTransform: ->
     return 'translate(' + (@viewport.center.x+@viewport.origin.x+@viewport.x-@viewport.offsetx) + ',' + (@viewport.center.y+@viewport.origin.y+@viewport.y-@viewport.offsety) + ')scale(' + @viewport.scale + ')'

    @svg.attr   'height', @viewport.height
    @rescale()
    # Update force size
    @force.size [@viewport.width, @viewport.height]

  rescale: ->
    @container.attr 'transform', @getContainerTransform()

    @viewport.center.x  = @viewport.width*0.5
    @viewport.center.y  = @viewport.height*0.5

    # Setup force
    forceLink = d3.forceLink()
      .id       (d) -> return d.id
      .distance ()  => return @parameters.linkDistance

    @force = d3.forceSimulation()
      .force 'link',    forceLink
      .force 'charge',  d3.forceManyBody()
      .force 'center',  d3.forceCenter(@viewport.center.x, @viewport.center.y)
      .on    'tick',    @onTick

    #@force.alphaDecay 0.03

    # @force = d3.layout.force()
    #   .linkDistance @parameters.linkDistance
    #   .linkStrength @parameters.linkStrength
