 
 class NodeAnimation
   constructor: (@node, @destpos, @duration) ->
-    @origpos = {x: @node.x, y: @node.y}
+    @origpos = null
 
   setPosition: (time) ->
+    if @origpos == null
+      @origpos = {x: @node.x, y: @node.y}
+
     pos = lerp2d(time/@duration, @origpos, @destpos)
     @node.move(pos.x, pos.y)
 

    name: 'sort by weight',
    action: (c, t) ->
      console.log('sort by weight')
      c.sortNodes( ((n1, n2) -> n1.value - n2.value), t)
  },
  {
    name: 'sort by alpha',
    action: (c, t) ->
      console.log('sort by alpha')
  },
  {
    name: 'Shannon-Fano',

  constructor: (@node_animations, @start_time) ->

  setPositions: (time) ->
    if @start_time == -1
      @start_time = time
    for a in @node_animations
      a.setPosition(time - @start_time)

