Skip to content

Instantly share code, notes, and snippets.

@eyy
Created July 16, 2013 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyy/6008186 to your computer and use it in GitHub Desktop.
Save eyy/6008186 to your computer and use it in GitHub Desktop.
jQuery animate using CSS animations
// add class, remove it at animation end. also callback
$.fn.animateClass = function(cls, cb) {
if (typeof cb === 'string') {
var endClass = cb;
cb = function() { $(this).addClass(endClass); };
}
return $(this).one('webkitAnimationEnd', function() {
$(this).removeClass(cls);
if (cb) cb.call(this);
}).addClass(cls);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment