Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jayeb/5078452 to your computer and use it in GitHub Desktop.
Save jayeb/5078452 to your computer and use it in GitHub Desktop.
Code for testing css-transition support on pseudo-elements for Modernizr. Forked from diseltravis's Gist: https://gist.github.com/dieseltravis/3908275 With improvements borrowed from Ryan Seddon's JSFiddle: http://jsfiddle.net/ryanseddon/vLdUq/2/
(function(Modernizr) {
var win = window,
transitionTo = "999px";
function _finish(result) {
Modernizr.addTest("csstransitionspseudos", result);
}
if (Modernizr.csstransitions && win.getComputedStyle) {
Modernizr.testStyles(
"#modernizr:after{content:'';font-size:0;"+Modernizr._prefixes.join("transition:2s linear;")+"}"+
"#modernizr.m:after{font-size:"+transitionTo+";}",
function(el) {
document.body.appendChild(el);
// Get the iniital computed style to force a browser style calc
win.getComputedStyle(el, ":after").fontSize;
el.className += "m";
try {
_finish(win.getComputedStyle(el, ":after").fontSize !== transitionTo);
el.parentNode.removeChild(el);
} catch (e) {}
}
);
} else {
_finish(false);
}
})(Modernizr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment