Some related questions I found from searching:
How does the 'fx' queue in jquery auto start?
I've read through the documentation on animate() for jquery but I am having some difficulty figuring out a solution to my problem.
What I am looking to do is queue up a series of animations on multiple elements. I want the animations to act in sequence, that is I want the current animation on an element to block animations on its own element, but not block animations on the other element.
Finally I want to be able to cancel the animations on one of the elements but allow the animations on the other(s) to continue.
I think that named jquery queues is what I want, however attempting that gave me animations that never started (I think this is due to the magic that is the 'fx' queue not being present on every other queue).
Thanks in advance!
EDIT:
Here's what I am kind-of looking for:
function someAnimationWrapper(queueName, element, animation) {
///<summary>
/// Places the animation specified into the queue of animations to be
/// run on that element. The animation queue is a named queue so
/// animations in the queue can be stopped at any time.
///</summary>
///<param name="queueName" type="String">
/// The name to assign to the element's animation queue.
///</param>
///<param name="element" type="jQuery">
/// jQuery object to perform the animations on.
///</param>
///<param name="animation" type="Object">
/// Animation properties for the animation call.
///</param>
// TODO: If magic needs to be done here this is a placeholder
element.animate(animation);
}
function magicallyStopMyQueue(queueName, clearQueue, jumpToEnd) { // May take element, whatever I need to get the job done
///<summary>Mirrors jQuery.prototype.stop(), but with the named queue.</summary>
///<param name="queueName" type="String">
/// Animation queue to stop.
///</param>
///<param name="clearQueue" type="Boolean">
/// See jQuery.prototype.stop()
///</param>
///<param name="jumpToEnd" type="Boolean">
/// See jQuery.prototype.stop()
///</param>
// TODO: some magics here
}
var e1 = $('.myDiv1'),
e2 = $('.myDiv2');
someAnimationWrapper('firstQueue', e1, { properties: { left: '-=16' }, duration: 100 });
someAnimationWrapper('firstQueue', e1, { properties: { left: '-=16' }, duration: 100 });
someAnimationWrapper('firstQueue', e1, { properties: { left: '-=16' }, duration: 100 });
someAnimationWrapper('secondQueue', e2, { properties: { left: '-=16' }, duration: 100 });
someAnimationWrapper('secondQueue', e2, { properties: { left: '-=16' }, duration: 100 });
someAnimationWrapper('secondQueue', e2, { properties: { left: '-=16' }, duration: 100 });
// Now I want to stop the first one
magicallyStopMyQueue('firstQueue', true, true);