我想做一个颜色淡入淡出,并在完成时运行一次函数。我可以使用bind
来执行此操作,它在transitionend
上运行回调。这是有效的,但是针对与元素相关的每个转换运行。限制/控制CSS过渡结束调用
CSS
多次转变:输出:(2) called
box-shadow: 2px 2px 5px red !important;
transition: all 2s ease-out ;
单过渡:输出:called
transition: background-color 2s ease-out !important;
background: red !important;
jQuery的:
$("#currentBlock").bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(event){
log("called");
$(this).unbind(event);
});
我想申请到的box-shadow的转变,但它调用transitionend
两次,而不是一次。如何限制回调被调用的时间,或者如果再次调用它,则取消它。
[transitionend event fire twice twice](http://stackoverflow.com/questions/18689031/transitionend-event-fire-twice) – 2014-11-14 21:55:11