Skip to content

Instantly share code, notes, and snippets.

@dandean
Created June 21, 2011 16:38
Show Gist options
  • Select an option

  • Save dandean/1038271 to your computer and use it in GitHub Desktop.

Select an option

Save dandean/1038271 to your computer and use it in GitHub Desktop.
Detect feature support for CSS3 transitions.
// warning: pseudo-code
var TRANSITIONS_SUPPORTED = false;
(function() {
var div = document.createElement('div');
div.innerHTML = '<div style="transition:color 1s linear;-ms-transition:color 1s linear;-o-transition:color 1s linear;-webkit-transition:color 1s linear;-moz-transition:color 1s linear;"></div>';
var prefixes = ['', '-webkit-', '-moz-', '-o-', '-ms-'];
for (var i=0; i<prefixes.length; i++) {
if (prefixes[i] + 'transition' in div.firstChild.style) {
TRANSITIONS_SUPPORTED = true;
break;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment