Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Created January 26, 2012 22:32
Show Gist options
  • Save patrickkettner/1685535 to your computer and use it in GitHub Desktop.
Save patrickkettner/1685535 to your computer and use it in GitHub Desktop.
keyframe test canidate
var D = document,
Db = D.body;
function De(x) { return D.createElement(x); }
function Dt(x) { return D.createTextNode(x); }
function Da(x) { return Db.appendChild(x); }
function Dr(x) { return Db.removeChild(x); }
function Dg(x) { return document.getElementById(x); }
var s = De('style'),
ss = s.styleSheet,
vendors = ['-moz-','-ms-','-webkit-', ''],
rules = [];
for (var i = vendors.length - 1; i > -1; i--) {
rules.push(Dt('@'+ vendors[i] + 'keyframes Qz {0%, 100% {margin-left: 500px}}'));
}
rules.push(Dt('#testingDiv {-webkit-animation: 1s Qz infinite 0s;-moz-animation: 1s Qz infinite 0s;-ms-animation: 1s Qz infinite 0s;animation: 1s Qz infinite 0s; }'));
if(ss) {
var ssc = ss.cssText;
for (var i = rules.length - 1; i > -1; i--) {
ssc += rules[i].nodeValue;
}
}
else {
for (var i = rules.length - 1; i > -1; i--) {
s.appendChild(rules[i]);
}
}
s.setAttribute('id','keyframe_test');
Da(s);
var testingDiv = De('div');
testingDiv.setAttribute('styleA','height: 1px;width: 1px;background: transparent;margin: 0px; padding: 0; position: absolute; z-index: -100');
testingDiv.setAttribute('id','testingDiv');
Da(testingDiv);
if (Dg('testingDiv').offsetLeft >= 500) {
Db.classList = Db.className += 'keyframes';
}
Dr(Dg('testingDiv'));
Dr(Dg('keyframe_test'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment