2014-04-02 3 views
0

와 JQuery와 애니메이션 시퀀스는 내가 가진 구조

$('.qwe').click(function(){ 

      $.when(
       $('#q1').animate({top: 100}, 1000), 
       $('#q2').animate({top: 200}, 500) 
      ).then(function() { 
       $('#q3').fadeOut(); 
      }); 

     }); 

내가 원하는대로 작동하지만 다른 기능에 애니메이션을 꺼내 원하는 :

function asd(){ 
     $('#q1').animate({top: 100}, 1000); 
     $('#q2').animate({top: 200}, 500); 
    } 
    $('.qwe').click(function(){ 

     $.when(asd()).then(function() { 
       $('#q3').fadeOut(); 
      } 
     ); 

    }); 

애니메이션이 동시에 수행되는 이유는 무엇입니까?

답변

0

이 시도 : JQuery와에 사용 콜백을

$('.qwe').click(function(){ 

     $('#q1').animate({top: 100}, 1000 , function() { 

       $('#q2').animate({top: 200}, 500, function() { 

         $('#q3').fadeOut(); 
       }); 
     }); 


    }); 
+0

내가 별도의 기능에 애니메이션을 취할 필요가 있기 때문에이 방법은 적합하지 않다 – mafaka