There is a slider pictures. When you click on the arrows, ul normally shifts left and right ... That is, when you click on the arrows, the position of ul changes:

 $('#vpered').click(function(){ $('ul').css('marginLeft', '-100px'); }); 

I didn’t write all the code. There are no problems with this, everything works fine.

But when I use the animate method, and click on the arrows, without waiting for the ul shift, it does not shift as it should ...

    2 answers 2

     $('#vpered').click(function(){ $('ul').animate('marginLeft', '=-100px'); }); 
    • It did not help - vinnie

    And what if you block the animation, for the time of its execution? Then you can not click until the animation is complete.

     logicAnimate = true; $('#vpered').click(function(){ if(logicAnimate){ logicAnimate = false; $('ul').animate({marginLeft : '=-100px'}, 500, function(){ logicAnimate = true; }); } });