//Setup Arrays that will hold the x,y,z of each element.
var x = new Array();
var y = new Array();
var z = new Array();
//Get the list of items.
var items = $('li');
//Animate the items.
function animate()
{
//Step through each item.
for(i = items.length - 1; i >= 0; i--){
//variables for movement.
var xVar = 50 + x[i] // x value
var yVar = 50 + y[i] * z[i]++; // y value, move towards bottom of screen
var zVar = 10 * z[i]++; // z value, text get larger.
//Check to see if text position is still on the screen.
// the #'s are %. 100 is far right or bottom, 0 is top or left.
// for z value it's the font size in %.
if (!xVar | xVar < 0 | xVar > 90|
yVar < 0 | yVar > 90 |
zVar < 0 | zVar > 1500)
{
//if it's off the screen randomly pick a starting place.
x[i]= Math.random() * 2 - 1;
y[i] = Math.random() * 2 - 1;
z[i] = 2;
}
else
{
//if it's still on the screen apply the appropiate styles.
$(items[i]).css("position", "absolute"); // make sure we can move the text around.
$(items[i]).css("top", xVar+"%"); // y value
$(items[i]).css("left", yVar+"%"); // x value
$(items[i]).css("fontSize", zVar+"%"); // font size (illusion of perspective.)
$(items[i]).css("opacity",(zVar)/1000); // fade in from the distance.
}
}
setTimeout(animate, 50);
}
animate();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.