Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
Created September 5, 2012 20:12
Show Gist options
  • Select an option

  • Save jakebellacera/3643848 to your computer and use it in GitHub Desktop.

Select an option

Save jakebellacera/3643848 to your computer and use it in GitHub Desktop.
jQuery.css with jQuery.animate fallbacks. Useful for CSS3 animations.
//= require modernizr
// Helper for performing css3 or jquery animations
;(function( window, $, undefined ){
'use strict';
$.fn.css3animate = function (rules, duration, easing, callback) {
var $this = $(this);
if (Modernizr.csstransitions) {
$this.css(rules);
if (callback) {
setTimeout(callback, duration);
}
} else {
$this.animate(rules,duration,easing,callback);
}
return $this;
}
})( window, jQuery );
@MarekZeman91
Copy link

O_O this is exactly what I wanted to make ... you were just a bit faster ... just 8 months :D

@jakebellacera
Copy link
Author

Honestly, this could be way better. Instead of requiring you to set the timing duration in CSS, you could set the timing duration on the elements itself. I just put it up to scratch a specific itch. Feel free to fork if you'd like ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment