Skip to content

Instantly share code, notes, and snippets.

@kirb
Last active December 13, 2015 17:58
Show Gist options
  • Select an option

  • Save kirb/4952053 to your computer and use it in GitHub Desktop.

Select an option

Save kirb/4952053 to your computer and use it in GitHub Desktop.
Image animation spinny thingy javascript
javascript:document.body.innerHTML+="<div id='spinnyThingyLoader' style='position:fixed;top:0;left:0;width:100%;z-index:9999;text-align:center;line-height:300px;font-size:40px'>Loading...</div>";var a=document.createElement("script");a.src="https://gist.github.com/kirbylover4000/4952053/raw/tehcodez.js";document.body.appendChild(a);void 0
// This is the full unminified code.
// I didn't make this, just cleaned it up and fixed
// it on the constantly changing Google Images.
(function() {
var repeats = 0, images = document.getElementsByTagName("img"), stuff = document.createElement("div"), exploder = !("webkitTransform" in document.body.style);
stuff.style.position = "fixed";
stuff.style.top = 0;
stuff.style.left = 0;
stuff.style.zIndex = 9998;
document.body.appendChild(stuff);
if (location.host.indexOf("www.google.co") == 0) {
var cssFix = document.createElement("style");
cssFix.innerText = ".rg_l { background: transparent; }";
document.body.appendChild(cssFix);
}
for (var i = 0; i < images.length; i++) {
if (images[i].parentNode != stuff) {
images[i].parentNode.removeChild(images[i]);
}
stuff.appendChild(images[i]);
images[i].style.position = "absolute";
images[i].style.zIndex = 9999;
}
(function animate() {
for (var i = 0; i < images.length; i++) {
if (images[i].parentNode != stuff) {
continue;
}
var left = (Math.sin(repeats * .1 + i * .25 + 1.6) * 300 + 300) + "px", top = (Math.cos(repeats * .05 + i * .24 + .24) * 200 + 200) + "px";
if (exploder) {
images[i].style.left = left;
images[i].style.top = top;
} else {
images[i].style.webkitTransform = "translate3d(" + top + ", " + left + ", 0)";
}
}
repeats++;
setTimeout(animate, exploder ? 5 : 15); //it's so damn fast with GPU acceleration.
})();
var loader = document.getElementById("spinnyThingyLoader");
if (loader) {
loader.parentNode.removeChild(loader);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment