2012-07-07 3 views
1

애니메이션을 실행 한 후 링크를 ​​따라 코드를 작성하려고합니다.jQuery - .animate 후 연결

아이디어는 "Gnoll"이 버튼을 눌렀다 고해서 링크로 연결된다는 것입니다.

그것은 그 안에없는 링크가 있습니다

이 지금까지 내 코드입니다.

$(document).ready(function(){ 


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

     $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');   
     $('.animateme').animate({ 
      left: '+=150', 
     }, 800, function() { 
      $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />'); 
     }); 
     $('.animateme').animate({ 
      left: '+=0', 
     }, 500); 

     $('.animateme').animate({ 
      left: '+=0', 
     }, 500, function() { 
      $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />'); 
      }); 

    }); 

    $('#AddOnbutton').click(function(){ 
     $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');   
     $('.animateme').animate({ 
      left: '+=250', 
     }, 1000, function() { 
      $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />') 

     }); 
     $('.animateme').animate({ 
      left: '+=0', 
     }, 1000, function() { 
      $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />'); 
      $("#AddOnbutton").html('<img src="Construct2/Images/redbutton.png" />'); 
      }); 


    }); 

}); 

코드는 아주 기본이고 당신이 볼 수있는 (또한, 버튼의 색상은 "히트"애니메이션. 지금까지 나는 그 일에 실패를 통해 중간에 대해 변경할 예정이다) . 링크 마지막

$('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />'); 

답변

0

후 약 0.5 초를 트리거해야 내가 좀 자신은 여전히 ​​:) 지금은 완벽하지 를 발견,하지만 괜찮아요.

$('a.home').click(function(){ 
    var newLocation = $(this).attr('href'); 
     $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');   
     $('.animateme').animate({ 
      left: '+=150', 
     }, 800, function() { 
      $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />'); 
     }); 
     $('.animateme').animate({ 
      left: '+=0', 
     }, 500); 

     $('.animateme').animate({ 
      left: '+=0', 
     }, 500, function() { 
      $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />'); 

      document.location = newLocation; 
      }); 
      return false;  
    });