Created
July 10, 2012 17:16
-
-
Save amoilanen/3084823 to your computer and use it in GitHub Desktop.
Simple animation for a web page, some of the elements are mixed up and re-positioned randomly at a fixed time interval.
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
//URL for a bookmarklet in a browser: | |
//javascript:var script = document.createElement("script"); script.src="https://raw.github.com/gist/3084823/6d8c6643e41092d09fa80c0db5234adbea7f94ea/mixup_page_animation.js"; document.body.appendChild(script);void(0); | |
(function(win) { | |
var elements = document.querySelectorAll("img, div"); | |
setInterval(function() { | |
for (var i = 0; i < elements.length; i++) { | |
elements[i].style.position = "fixed"; | |
elements[i].style.top = Math.floor(Math.random() * win.innerHeight).toString() + "px"; | |
elements[i].style.left = Math.floor(Math.random() * win.innerWidth).toString() + "px"; | |
}; | |
}, 1000); | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment