【发布时间】:2014-11-15 21:47:48
【问题描述】:
我想做一个颜色渐变,并在完成后运行一次函数。我可以使用bind 来做到这一点,它在transitionend 上运行回调。这可行,但会针对与元素关联的每个过渡运行。
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 两次,而不是一次。如何限制回调被调用的时间,或者如果再次调用则取消它。
【问题讨论】: