Skip to content

Instantly share code, notes, and snippets.

@simplelife7
Created December 3, 2013 02:51
Show Gist options
  • Save simplelife7/7763179 to your computer and use it in GitHub Desktop.
Save simplelife7/7763179 to your computer and use it in GitHub Desktop.
【JS】判断动画transition是否结束函数
(function($){
/**
* transitionend
* @public
* @function
* @name $.fn.onTransitioned
* @param {Function} cbk 事件处理函数
*/
$.fn.onTransitioned = function (cbk) {
return this.each(function () {
if (cbk===false) {
$(this).unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd");
return;
}
$(this).bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", cbk);
});
};
})(jQuery);
$('.xxx').onTransitioned(function(){
$(this).onTansitioned(false).addClass('yyy');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment