Skip to content

Commit d9b5148

Browse files
committed
Made runner use requestAnimationFrame if found, otherwise fallback to setTimeout
1 parent baf363a commit d9b5148

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/runner.coffee

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Runner
2626

2727
settings:
2828
autostart: false
29-
interval: 20
3029
countdown: false
3130
stopAt: null
3231
startAt: 0
@@ -75,18 +74,19 @@ class Runner
7574
@running = true
7675
@reset() if not @startTime or @finished
7776
@lastTime = $.now()
78-
@interval = setInterval(=>
79-
@update()
77+
step = =>
78+
if @running
79+
@update()
80+
_requestAnimationFrame(step)
8081
return
81-
, @settings.interval)
8282

83+
_requestAnimationFrame(step)
8384
@fire 'runnerStart'
8485
return
8586

8687
stop: ->
8788
if @running
8889
@running = false
89-
clearInterval @interval
9090
@update()
9191
@fire 'runnerStop'
9292
return

0 commit comments

Comments
 (0)