$.Deferred(function(dfr) {
$("#container > div").each(function() {
var $div = $(this);
dfr = dfr.pipe(function() {
return $div.fadeIn();
});
});
}).resolve();
Is there a way to load dfr separately in the above code and then pass it into $.Deferred() something like....
$("#container > div").each(function() {
var $div = $(this);
dfr = dfr.pipe(function() {
return $div.fadeIn();
});
});
$.Deferred(function(dfr) { }).resolve();
http://jsfiddle.net/realwork007/KgY33/25/ Similiar to this example but only thing is I will be populating the dfr seperately.
Edit: I am writing to visualize selection sort algorithms and I have 3 to 4 helper function like change backgroundOfBlock(),blink(index) and swap(from,to)
So my selection sort visualization would be like:
function selectionSort(items){
var len = items.length, min;
for (i=0; i < len; i++){
blink(blocks[i]);// to show It is selected
//set minimum to this position
min = i;
changebackground(blocks[i]);//show it is min
//check the rest of the array to see if anything is smaller
for (j=i+1; j < len; j++){
if (items[j] < items[min]){
min = j;
swap(blocks[min], blocks[j]);//swap animation function
}
}
.
.
.
.
If I run this method all animation run at once together but I need them to run sequencially...
using any technique...