Skip to content

Instantly share code, notes, and snippets.

@z-------------
Last active August 29, 2015 14:14
Show Gist options
  • Save z-------------/808ef0cc55abbb8cd9eb to your computer and use it in GitHub Desktop.
Save z-------------/808ef0cc55abbb8cd9eb to your computer and use it in GitHub Desktop.
var rolleyroll = function(duration){
var newStyleText = "@keyframes rolleyroll { from { transform: rotate(0) } to { transform: rotate(1turn) } }\n@-webkit-keyframes rolleyroll { from { -webkit-transform: rotate(0) } to { -webkit-transform: rotate(1turn) } }";
var newStyleElem = document.createElement("style");
newStyleElem.textContent = newStyleText;
document.head.appendChild(newStyleElem);
var elements = document.querySelectorAll("body, body *");
for (var i = 0; i < elements.length; i++) {
var styleString = "rolleyroll " + (duration || 5) + "s infinite linear";
elements[i].style.animation = styleString;
elements[i].style.webkitAnimation = styleString;
}
};
/*
rolleyroll(10)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment