Created
June 23, 2015 01:55
-
-
Save GirlBossRush/d8e40ce31f1dc0b65c54 to your computer and use it in GitHub Desktop.
Creepy DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var | |
elements = Array.prototype.slice.call(document.querySelectorAll("div, header, footer, img, p, span")) | |
elements.forEach(function (element) { | |
element._offset = 0.2; | |
element.style.transformOrigin = "left top" | |
element.style.transition = "transform 3s ease-in" | |
}) | |
function tilt (element) { | |
if (Math.random() < 0.5) { | |
return; | |
} | |
element._offset *= 1.0005 | |
element.style.transform = [ | |
"rotate(", | |
element._offset, | |
"deg) ", | |
"translateX(", | |
element._offset * 5, | |
"px)" | |
].join("") | |
} | |
setInterval(function () { | |
requestAnimationFrame(function () { | |
elements.forEach(tilt) | |
}) | |
}, 5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment