decodeURI

jQuery FxQueues plugin 2.0

Latest version (2.0.3) only works with jQuery 1.3.x. Check the releases for earlier versions that work with jQuery 1.0.x and 1.2.x

Introduction

The new version of this plugin is based on a script John Resig started some time ago (I came across his code afterlaunching the first version of this plugin). I adapted the code and added the scope stuff, created a new example page and also created some unit tests (which need some improvement, but are a good start).

If you find any bugs or have doubts or comments, feel free to contact me.


Download


Queues

A queue is an array that may contain animations to perform and/or
scopes.

You just have to pass its name (with the animate’s “queue” argument) to add an animation
to a queue. If the queue doesn’t exist, then it creates it automatically.
In case a name is not passed, then a queue for the element is created.


Scopes

What happens if you needed to enqueue not a single effect, but a group of effects
to be played altogether? This is where scopes come to save the day.

A scope is an object that can be contained in a queue. It is an array that contains
only animations to perform. When a scope is dequeued, it automatically
plays all the animations it contains.

You just have to pass its name (with the animate’s “scope” argument) to add an animation
to a queue’s scope. If the scope doesn’t exist, then it creates it automatically.


animate arguments:

  • queue: (string) Name of the queue. If it doesn’t exist, it creates the new queue. If you pass false no queue is created.
  • scope: (string) Name of the scope.
  • position: (”front”|”end”) Queue position where animation (or scope,
    if passed) is queued.
  • preDelay: (int) Milliseconds to wait before starting the next in queue.
  • postDelay: (int) Milliseconds to wait after finishing the animation.

Usage:

animate(properties, speed, easing, callback, queue, scope, queuePosition, wait)

$(”#myId”).animate(
{marginLeft: “10px”},
{speed: 500,
queue: “first”
});

Since these arguments are available in the new
animate implementation,
they can be used in the other effects, like:

$(”#myId”).fadeIn({
speed: 500,
queue: “first”,
scope: “global”,
preDelay: 500
});


Working with the queues

Now you have a $.fxqueue(”queueName”) to get the queue. The object has three useful methods:

  • $.fxqueue(”queueName”).pause()
  • $.fxqueue(”queueName”).start()
  • $.fxqueue(”queueName”).stop() (The queue is cleared.)

Check it out:


Changelog

  • 02-15-2009:
    • Version 2.0.3: Works now with jQuery 1.3.x
  • 04-13-2008:
    • Version 2.0.2: [Fix] Check that animate is not being called by a null selection.
    • Version 2.0.1: [Fix] Check that complete arg is a function before applying it.
  • 03-13-2008:
    • Version 2.0: Completely rewritten, based on John Resig’s code.
  • 11-21-2007:
    • Renamed functions (start, stop and clear)
    • Fixed stop method when stopping an animation queued with a wait time.
  • 11-19-2007: First release.

7 Responses

Subscribe to comments with RSS.

  1. Dr. Green said, on July 21, 2008 at 10:23 am

    Hi!
    Great plugin. I’m not a big java programmer.
    Can any queue be loopable? If the answer is “yes”, would You like to explain, how?

    Thx for this plug., and for Your time!

  2. luciano.panaro said, on October 7, 2008 at 11:48 am

    Thanks for your comment (and I’m sorry I’m replying so late, I’ve been extremely busy…).

    Being a queue, the whole point is that you cannot “loop” it, but maybe if you explain what you wanted to do I could help you out.

  3. [...] jQuery FxQueues 2.0: The latest version of Luciano German Panaro’s effects-queue plugin. It rewires jQuery’s native global effects queue with fine-grained effects queues like the ones that ship with Scriptaculous. [...]

  4. [...] jQuery FxQueues plugin 2.0 [...]

  5. Apt Tech Team » Delay in jQuery said, on August 3, 2009 at 1:01 am

    [...] the prototype library, do not contain a delay function. If you work with animations and effects the jQuery FxQueues plugin will be [...]


Leave a Reply