Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrade to newer version of Timer.js with fixed API for Timer#bind.

  • Loading branch information...
commit 1e6dfb1dc5b46322cfe9c57ba2dacd0793c6be3a 1 parent af5acb4
@jimmycuadra authored
View
2  source/javascripts/models/store.js.coffee
@@ -19,7 +19,7 @@ class ph.Store extends Backbone.Model
@on("change", @persist, this)
@timer = new Timer
- @timer.every(1, @addTick)
+ @timer.every(100, @addTick)
@timer.start()
checkHighScore: (store, newScore) ->
View
11 source/javascripts/vendor/timer.js
@@ -69,7 +69,7 @@
setTimeout(function loopsyloop() {
self._ticks++;
for (var i = 0, l = self._notifications.length; i < l; i++) {
- if (self._ticks % self._notifications[i].ticks === 0) {
+ if (self._notifications[i] && self._ticks % self._notifications[i].ticks === 0) {
self._notifications[i].callback.call(self._notifications[i], {
ticks: self._ticks,
resolution: self._resolution
@@ -111,12 +111,7 @@
},
bind: function(when, callback) {
if (when && callback) {
- var ticks;
- if (typeof when === 'number') {
- ticks = when;
- } else {
- ticks = millisecondsToTicks(timeStringToMilliseconds(when), this._resolution);
- }
+ var ticks = millisecondsToTicks(timeStringToMilliseconds(when), this._resolution);
this._notifications.push({
ticks: ticks,
callback: callback
@@ -129,7 +124,7 @@
this._notifications = [];
} else {
for (var i = 0, l = this._notifications.length; i < l; i++) {
- if (this._notifications[i].callback === callback) {
+ if (this._notifications[i] && this._notifications[i].callback === callback) {
this._notifications.splice(i, 1);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.