Created
January 31, 2012 17:39
-
-
Save dgalarza/1711774 to your computer and use it in GitHub Desktop.
Raptor Queue Animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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