https://github.com/mjc-gh/deferred-queue.js
jQuery Deferred Queue: for some syntaxical sugar around $.when
https://github.com/mjc-gh/deferred-queue.js
Last synced: 7 months ago
JSON representation
jQuery Deferred Queue: for some syntaxical sugar around $.when
- Host: GitHub
- URL: https://github.com/mjc-gh/deferred-queue.js
- Owner: mjc-gh
- Created: 2011-10-29T05:15:54.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2013-08-27T14:23:49.000Z (about 12 years ago)
- Last Synced: 2025-03-15T08:33:34.157Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 109 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
jQuery Deferred Queue:
Easily execute sets of asynchronous JavaScript code. The queue can be paused and resume on demand.
This especially useful when chaining together groups of animations that may vary in duration.
Example:
var animator = $.DeferredQueue();
function move_to(elem, position){
// return a function that gets called when set is executed
return function(){
// function returns a promise
return elem.animate(pos, Math.random() * 5000);
}
}
// each set gets called with $.when when it is dequeued
animator.queue(
move_to(one, { top: 250, left: 250 }),
move_to(two, { top: 250, left: 50 }),
).queue(
move_to(one, { top: 50, left: 50 }),
move_to(two, { top: 50, left: 250 }),
).queue(
move_to(one, { top: 250, left: 250 }),
move_to(two, { top: 250, left: 50 }),
).queue(
move_to(one, { top: 50, left: 50 }),
move_to(two, { top: 50, left: 250 }),
);