     @running = false
 
   unpause: () ->
+    @lastTime = @currentTime()
     @running = true
 
   emitPosition: () ->
     return unless @outPorts.value.isAttached()
     pos = @elapsedTime / @duration
-    pos = 1 - pos unless @direction
+    pos = 1.0 - pos unless @direction
     @outPorts.value.send(pos)
     @outPorts.value.disconnect()
 

    return unless @running

    # Measure delta
    delta = 0
    if @lastTime
      t = @currentTime()
      delta = t - @lastTime
      @lastTime = t

    # Add to elapsedTime
    if @direction then @elapsedTime += delta else @elapsedTime -= delta

    # End case
    if @isComplete()
      @position = if @direction then 1.0 else 0.0
      @emitPosition()
      @stop()
      return

    # Continue case
    if @repeat < 1
      @emitPosition()
      return

    # Loop case
    @elapsedTime = @elapsedTime - @duration

    @direction = !@direction if @autoreverse
    @repeat -= 1

    @emitPosition()



    @running = false
    @duration = 500
    @repeat = @repeatCount = 0
    @reverse = false
    @autoreverse = false
    @direction = true

    # control
    @inPorts.start.on 'data', () =>
