Skip to content

Instantly share code, notes, and snippets.

@oreillyross
Created April 8, 2016 11:59
Show Gist options
  • Save oreillyross/5e387b760c9f2c22b3c9c4918ae91d38 to your computer and use it in GitHub Desktop.
Save oreillyross/5e387b760c9f2c22b3c9c4918ae91d38 to your computer and use it in GitHub Desktop.
This code will check to see if CSS animation support is available: Query the animation boolean value
var animation = false,
animationstring = 'animation',
keyframeprefix = '',
domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),
pfx = '',
elm = document.createElement('div');
if( elm.style.animationName !== undefined ) { animation = true; }
if( animation === false ) {
for( var i = 0; i < domPrefixes.length; i++ ) {
if( elm.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) {
pfx = domPrefixes[ i ];
animationstring = pfx + 'Animation';
keyframeprefix = '-' + pfx.toLowerCase() + '-';
animation = true;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment