Skip to content

Instantly share code, notes, and snippets.

@andrewplummer
Last active August 29, 2015 14:21
Show Gist options
  • Save andrewplummer/53ce9bf6fc895768210b to your computer and use it in GitHub Desktop.
Save andrewplummer/53ce9bf6fc895768210b to your computer and use it in GitHub Desktop.
Spin all da things
var style = document.createElement('style');
style.innerHTML = [
'@-moz-keyframes spin {',
'from { -moz-transform: rotate(0deg); }',
'to { -moz-transform: rotate(360deg); }',
'}',
'@-webkit-keyframes spin {',
'from { -webkit-transform: rotate(0deg); }',
'to { -webkit-transform: rotate(360deg); }',
'}',
'@keyframes spin {',
'from {transform:rotate(0deg);}',
'to {transform:rotate(360deg);}',
'}'
].join('');
document.querySelector('head').appendChild(style);
Array.prototype.slice.call(document.querySelectorAll('body a')).forEach(function(el) {
var s = el.style;
var anim = 'spin 1s infinite linear'
if (s.webkitAnimation != null) {
s.webkitAnimation = anim;
} else if (s.mozAnimation != null) {
s.mozAnimation = anim;
} else if (s.animation != null) {
s.animation = anim;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment