Skip to content

Instantly share code, notes, and snippets.

@fabiomcosta
Created May 16, 2012 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiomcosta/2714969 to your computer and use it in GitHub Desktop.
Save fabiomcosta/2714969 to your computer and use it in GitHub Desktop.
Modernizr feature-detect for css transitions on pseudos elements
// transitions pseudos test.
// check if CSS3 transitions take effect on pseudo elements.
// https://github.com/Modernizr/Modernizr/issues/295
// This test is asynchronous. Watch out.
// without csstransitions this check makes no sense and
// without getComputedStyle we wont be able to get the style from a pseudo element
if (Modernizr.csstransitions && window.getComputedStyle) {
Modernizr.testStyles(
'#modernizr:after{content:"";font-size:0;'+ Modernizr._prefixes.join('transition:2s;') +'}' +
'#modernizr._m:after{font-size:999px;}',
function(elem) {
elem.className = '_m';
setTimeout(function() {
Modernizr.addTest(
'csstransitionspseudos',
window.getComputedStyle(elem, ':after').fontSize !== '999px'
);
}, 50);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment