views:

86

answers:

0

I have created a tab system that I want to be able to be scrolled. I am trying to implement the scrolling feature now. The only problem that I am having is that it will keep scrolling if they keep clicking the button and dont wait for it to finish. So I am trying to implement a variable that stores whether it is scrolling or not. Here is my tabLeft() function:

if(tab_moving){
 return false;
} else {
 if(true){
  //set the tab_moving to true
  tab_moving = true;

  $(".tab_link").each(function(){
   $(this).css("position","relative");
   $(this).animate({"left":"-=50px"});
  });

  //set the tab_moving to false
  tab_moving = false;
 }
}

However, it keeps doing the same thing. I think this is because it is just starting the each and then setting the tab_moving to false before it even finishes looping through the each. Is there a way for me to have the tab_moving set to false when it completes the each function?