Skip to content

Instantly share code, notes, and snippets.

@jschomay
Created May 19, 2013 17:41
Show Gist options
  • Save jschomay/5608377 to your computer and use it in GitHub Desktop.
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
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