Created
May 19, 2013 17:41
-
-
Save jschomay/5608377 to your computer and use it in GitHub Desktop.
little loop to "explode/scatter" any page's - each element moves in a random direction/speed along its x axis
For demo, copy code, go to random website, paste in console
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 elems=document.querySelectorAll("body *"); | |
var l=elems.length; | |
var i, c, move, x = 1; | |
var A = function (){ | |
for(i=0; i-l; i++){ | |
c=elems[i].style; | |
move = elems[i].move | |
if (!move){ | |
move=(Math.random()*8*(Math.round(Math.random())?1:-1)); | |
} | |
move *= x; | |
elems[i].move = move; | |
c['-webkit-transform'] = "translateX(" + move + 'px)'; | |
} | |
x++; | |
}; | |
//Loop | |
setInterval(function(){A()},60); | |
console.log("Page Exploded!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment