Skip to content

Instantly share code, notes, and snippets.

@GirlBossRush
Created June 23, 2015 01:55
Show Gist options
  • Save GirlBossRush/d8e40ce31f1dc0b65c54 to your computer and use it in GitHub Desktop.
Save GirlBossRush/d8e40ce31f1dc0b65c54 to your computer and use it in GitHub Desktop.
Creepy DOM
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