Skip to content

Commit 3c055c7

Browse files
committed
Updated distributables
1 parent d9b5148 commit 3c055c7

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

build/jquery.runner-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/jquery.runner-min.js.gz

46 Bytes
Binary file not shown.

build/jquery.runner.coffee

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ _uid = 1
88
pad = (num) -> (if num < 10 then '0' else '') + num
99
uid = -> 'runner' + _uid++
1010

11+
_requestAnimationFrame = ((win, raf) ->
12+
win['webkitR' + raf] or win['r' + raf] or win['mozR' + raf] or win['msR' + raf] or (fn) -> setTimeout(fn, 30)
13+
)(window, 'equestAnimationFrame')
14+
1115
formatTime = (time, settings) ->
1216
settings = settings or {}
1317
steps = [3600000, 60000, 1000, 10]
@@ -61,7 +65,6 @@ class Runner
6165

6266
settings:
6367
autostart: false
64-
interval: 20
6568
countdown: false
6669
stopAt: null
6770
startAt: 0
@@ -110,18 +113,19 @@ class Runner
110113
@running = true
111114
@reset() if not @startTime or @finished
112115
@lastTime = $.now()
113-
@interval = setInterval(=>
114-
@update()
116+
step = =>
117+
if @running
118+
@update()
119+
_requestAnimationFrame(step)
115120
return
116-
, @settings.interval)
117121

122+
_requestAnimationFrame(step)
118123
@fire 'runnerStart'
119124
return
120125

121126
stop: ->
122127
if @running
123128
@running = false
124-
clearInterval @interval
125129
@update()
126130
@fire 'runnerStop'
127131
return

build/jquery.runner.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (c) 2013 Jyrki Laurila <https://github.com/jylauril>
55
*/
66
(function() {
7-
var Runner, formatTime, meta, pad, runners, uid, _uid;
7+
var Runner, formatTime, meta, pad, runners, uid, _requestAnimationFrame, _uid;
88

99
meta = {
1010
version: "2.3.0",
@@ -23,6 +23,12 @@
2323
return 'runner' + _uid++;
2424
};
2525

26+
_requestAnimationFrame = (function(win, raf) {
27+
return win['webkitR' + raf] || win['r' + raf] || win['mozR' + raf] || win['msR' + raf] || function(fn) {
28+
return setTimeout(fn, 30);
29+
};
30+
})(window, 'equestAnimationFrame');
31+
2632
formatTime = function(time, settings) {
2733
var i, len, ms, output, prefix, separator, step, steps, value, _i, _len;
2834
settings = settings || {};
@@ -90,7 +96,6 @@
9096

9197
Runner.prototype.settings = {
9298
autostart: false,
93-
interval: 20,
9499
countdown: false,
95100
stopAt: null,
96101
startAt: 0,
@@ -146,24 +151,28 @@
146151
};
147152

148153
Runner.prototype.start = function() {
149-
var _this = this;
154+
var step,
155+
_this = this;
150156
if (!this.running) {
151157
this.running = true;
152158
if (!this.startTime || this.finished) {
153159
this.reset();
154160
}
155161
this.lastTime = $.now();
156-
this.interval = setInterval(function() {
157-
_this.update();
158-
}, this.settings.interval);
162+
step = function() {
163+
if (_this.running) {
164+
_this.update();
165+
_requestAnimationFrame(step);
166+
}
167+
};
168+
_requestAnimationFrame(step);
159169
this.fire('runnerStart');
160170
}
161171
};
162172

163173
Runner.prototype.stop = function() {
164174
if (this.running) {
165175
this.running = false;
166-
clearInterval(this.interval);
167176
this.update();
168177
this.fire('runnerStop');
169178
}

0 commit comments

Comments
 (0)