Wait until "if" statement is done?
Is it that possible?
- if($("#results").hasClass("busy"))
- {
- $("#gradiente").fadeOut(800, function() {
- $(this).remove();
- });
- }
-
- $("#results").append("<div style='height: "+ altura +"px; width: "+ anchura +"px;' id='gradiente' />");
-
- for(i=0; i<=altura; i++) {
-
- var r = desde_rgb[0]-(step_r*i);
- var g = desde_rgb[1]-(step_g*i);
- var b = desde_rgb[2]-(step_b*i);
-
- $("#gradiente").append("<span class='grano' style='background: rgb("+ Math.round(r) +", "+ Math.round(g) +", "+ Math.round(b) +");' />");
- }
-
- $("#gradiente").css({'opacity': '0'});
- $("#results").animate({"height": $("#gradiente").height(), "padding": "15px"}, 1800, function() {
- $("#gradiente").fadeTo(800, 1);
- }).addClass("busy");
I want that because, in the above code, the for loop doesn't wait to the if statement is finished and overrides the .fadeTo function. I don't know, i think that what i'am looking for is some kind of "manual callback" :P
Is it understandable? hahaha