jquery animation done

谁都会走 提交于 2019-12-24 02:03:34

问题


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:


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



来源:https://stackoverflow.com/questions/1768464/jquery-animation-done

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!