Skip to content

Instantly share code, notes, and snippets.

@dgalarza
Created March 14, 2012 17:36
Show Gist options
  • Save dgalarza/2038118 to your computer and use it in GitHub Desktop.
Save dgalarza/2038118 to your computer and use it in GitHub Desktop.
jQuery CSS Transition Fallbacks
(function (window, doc, $, undefined) {
// Check for CSS3 Transition Support
var css_transitions = function() {
var el = doc.createElement('div');
var vendors = ['Khtml', 'Ms', 'Moz',' Webkit','O'];
for (var i = 0, len = vendors.length; i < len; i++) {
var prop = vendors[i] + 'Transition';
if (prop in el.style) return true;
}
return false;
}();
/**
* Assuming a transition CSS definition is applied to .animate-me for width
* @see http://api.jquery.com/animate/
* @see http://api.jquery.com/css/
*/
var method = (css_transitions) ? 'css' : 'animate';
$('.animate-me')[method]({
width: 100
});
})(window, document, jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment