views:

203

answers:

1

Ok so I have a tab class that is scrollable which works fine, but now I want to hide the controls if they cannot scroll in the direction that they are trying to go. so I have something like this;

function tab_left(){
  $(".tab_link").each(function(){
    //animation here
  });
}

Then I want to create a function that will make sure that none of them are animated(because if they are there position will not be correct). Then it will fix the image to either display or not. The problem I am having is checking that none of them are being animated. Any help is appreciated.

+1  A: 

To check if an element is being animated you can do this:

if( $("#the-great-div").is(":animated") ){
  alert("Yay!");
}

Or if you want, you can set a callback to be called when the animation is done: http://docs.jquery.com/Effects/animate

var finished = 0;
var callback = function (){
  // Do whatever you want.
  finished++;
}
$("#div").animate(params, duration, null, callback);

That callback parameter is usually available in all animation functions, not just animate. Finally, if you want to keep track of how many items have finished, a global variable should do (like finished in this case).

Seb
I know how to check if an element is animated but if its animated i want it to keep checking until the element is not animated to run the function that checks its position, or just to run the function after the animation is complete would be a better solution.
ngreenwood6