Skip to content

Instantly share code, notes, and snippets.

@dgalarza
Created January 31, 2012 17:39
Show Gist options
  • Save dgalarza/1711774 to your computer and use it in GitHub Desktop.
Save dgalarza/1711774 to your computer and use it in GitHub Desktop.
Raptor Queue Animation
interval_callbacks : {};
intervals : {}
queue_animation : function (interval, delay, fn, id) {
_animation_stack.push_to_queue(interval, fn, id);
_animation_stack.create_interval(interval, delay);
},
push_to_queue : function (interval, fn, id) {
if (!this.interval_callbacks[interval]) this.interval_callbacks[interval] = {};
this.interval_callbacks[interval][id] = fn;
}
create_interval : function (name, interval) {
if (this.intervals[name]) return;
this.intervals[name] = setInterval(function () {
var queue = _animation_stack.interval_callbacks[name];
if (queue && !raptor.obj_empty(queue)) {
for (var fn in queue) queue[fn].call();
}
else {
clearInterval(_animation_stack.intervals[name]);
delete _animation_stack.intervals[name];
}
}, interval);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment