开发者

jquery animation done

Ok so I have a tab cl开发者_如何学Pythonass 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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜