adjustFrameWaitTime in Movie#stop

This commit is contained in:
Marcin Kulik 2012-04-15 21:11:25 +02:00
parent 07eeb1e81b
commit 0d77b843d3

View File

@ -75,13 +75,19 @@ class AsciiIo.Movie
@nextFrame() @nextFrame()
stop: -> stop: ->
clearInterval @nextFrameTimeoutId
@playing = false @playing = false
@cancelNextFrameProcessing()
now = @now() now = @now()
@adjustFrameWaitTime(now)
@pausedAt = now
cancelNextFrameProcessing: ->
clearInterval @nextFrameTimeoutId
adjustFrameWaitTime: (now) ->
resumedAt = @resumedAt or @lastFrameAt resumedAt = @resumedAt or @lastFrameAt
currentWaitTime = now - resumedAt currentWaitTime = now - resumedAt
@totalFrameWaitTime += currentWaitTime @totalFrameWaitTime += currentWaitTime
@pausedAt = now
restart: -> restart: ->
@reset() @reset()