Skip to content

Instantly share code, notes, and snippets.

@michsch
Created May 23, 2013 19:38
Show Gist options
  • Save michsch/5638830 to your computer and use it in GitHub Desktop.
Save michsch/5638830 to your computer and use it in GitHub Desktop.
CSS3 feature detection for transitions without Modernizr. Found here: http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
/**
* original found here: http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
*/
var featureDetection = ( function( exports, root, document ) {
"use strict";
exports.transition = function() {
var body, bodyStyle, feature, prefix;
body = document.body || document.documentElement;
bodyStyle = body.style;
feature = 'transition';
if(typeof bodyStyle[feature] === 'string') {
return true;
}
// Tests for vendor specific prop
prefix = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'];
feature = feature.charAt(0).toUpperCase() + feature.substr(1);
for( var i = 0; i < prefix.length; i++ ) {
if(typeof bodyStyle[prefix[i] + feature] === 'string') {
return true;
}
}
return false;
}
return exports;
})( featureDetection || {}, window, document );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment