I have this function here
$(document).keydown(function(e){
if (e.which == 39) {
goRight();
}
if (e.which == 37) {
goLeft();
};
});
And I want that: if I press the right or the left arrow keys, calling any of my functions (goRight or goLeft), I can only execute the other key pressing action after the function do it’s job. What I want is similar to the stop() function to animations. Because when I press left/right very quickly all my margin get bugged.
The goRight function is this
function goRight(){
if(!$('.livin').hasClass('blog') ){
$('#contentGeral .containerConteudo ul').stop().animate({marginLeft:'-=800'},function(){
removeClasses();
addClasses();
});
}
else{
$('#contentGeral .containerConteudo ul').stop().animate({marginLeft:'0'}, function(){
removeClasses();
addClasses();
});
}
}
The goLeft is analogous.
Thanks in advance for the help!
The method
.stop(true,true)made this work. Thanks 3nigma for the tip.