I am working on a website that has animations that change every week. With that in mind, I found a need for an animation queue with the ability to set a time value for each event. So here is what I came up with:
The plugin accepts, in its options, an array of events in this format:
[ [callback,[args],time],[callback,[args],time] ]
and so on. I have built it to have two time modes: Absolute and Relative. Absolute will fire events based on the overall time elapsed for the object. (keep in mind, if an alert is shown in any callback methods, all triggers that were supposed to happen will happen immediately following the close of the alert) In relative, all events fire based on the time in which the previous event was fired. Therefore, if a callback brings up an alert, the following event will not fire until its time specification after the alert is closed.
To make sure that we do not waste any time in loops for events that should trigger at the same time, the plugin creates a master list and uses additional setTimeout calls to call all methods for that time period at once.
Additional options include:
autoPlay: [true|false] does the eventlist start firing as soon as the init is finished.
I know the code is rough, I'm looking for ideas on how to improve it, and maybe clean it up a bit. Also, is there something out there like this and if not, is this worth it?