promis powinno być ok(wydawało mi się że jest przestarzały), ale po całym dniu studiowania nadal nie mogę go poprawnie użyć z moim kodem.
$(document).ready(function() {
var right=$('.a #first').width();
var height=$('.a #first').height();
$('.a #first').show('slow',function(){
$('.a #first').animate({right:0},500,
function(){$('.a #first').animate({width:0,height:height},500,
function(){$('.b #first').css({'display':'block','height':height}).animate({width:right,height:height},500,
function(){$('.b #first').animate({right:0},500,
function(){$('.b #first').animate({width:0,height:height},500,
function(){$('.c #first').css({'display':'block','height':height}).animate({width:right,height:height},500,
function(){$('.c #first').animate({right:0},500)})
})
})
})
})
})
});
$('.a #first').promise().done(function(){
$('.a #sec').show('slow',function(){
$('.a #sec').animate({right:0},500,
function(){$('.a #sec').animate({width:0,height:height},500,
function(){$('.b #sec').css({'display':'block','height':height}).animate({width:right,height:height},500,
function(){$('.b #sec').animate({right:0},500,
function(){$('.b #sec').animate({width:0,height:height},500,
function(){$('.c #sec').css({'display':'block','height':height}).animate({width:right,height:height},500,
function(){$('.c #sec').animate({right:right},500)})
})
})
})
})
})
})
});
$('.a #sec').promise().done(function(){
$('.a #third').show('slow',function(){
$('.a #third').animate({right:0},500,
function(){$('.a #third').animate({width:0,height:height},500,
function(){$('.b #third').css({'display':'block','height':height}).animate({width:right,height:height},500,
function(){$('.b #third').animate({right:0},500,
function(){$('.b #third').animate({width:0,height:height},500,
function(){$('.c #third').css({'display':'block','height':height}).animate({width:right,height:height},500,
function(){$('.c #third').animate({right:2*right},500)})
})
})
})
})
})
})
});
$( '.a #third').promise().done(function(){
$('.a #fourth').show('slow',function(){
$('.a #fourth').animate({right:0},500,
function(){$('.a #fourth').animate({width:0,height:height},500,
function(){$('.b #fourth').css({'display':'block','height':height}).animate({width:right,height:height},500,
function(){$('.b #fourth').animate({right:0},500,
function(){$('.b #fourth').animate({width:0,height:height},500,
function(){$('.c #fourth').css({'display':'block','height':height}).animate({width:right,height:height},500,
function(){$('.c #fourth').animate({right:2*right},500)})
})
})
})
})
})
})
});
})
W tym przypadku pierwsza i druga część kodu działa poprawnie, asynchronicznie, ale potem zaczynają się problemy. Dwa ostatnie etapy niestety już wyświetlają się razem. Przy próbach użycia then w ogóle cały czas były błędy. Przy podzieleniu tego na cztery funkcje i też był problem przy trzecim i czwartym etapie. Może podpowiecie coś jeszcze.