.animate two column box drop - top: misaligns
Warning: I'm a jquery nooobie. Please be kind.
I'm trying to stack 40 div boxes, in two columns with an animate function. I have no problem doing this by;
$(".place2").animate({top: '+675px'}, 1125, 'easeOutBounce');
and then changing the "place2" to the next div number and decrease the top by 25 for every second div. In order to make the coding easier i thought i'd try my hand at a do..while loop. This is where things get funky. I now have this code:
- $(document).ready(function(){
- // Start animation
- var i=0;
- var time1=1000;
- var time2=1050;
- var timeInc=100;
- var tp=700;
- var place = ".place" + i;
- $("#places").click(function(){
- do {
- $(place).animate({top: "+"+tp+"px"}, time1, 'easeOutBounce');
- i++;
- place = ".place" + i;
- $(place).animate({top:"+"+tp+"px"}, time2, 'easeOutBounce');
- time1 = time1 + timeInc;
- time2 = time2 + timeInc;
- tp = tp - 25;
- }
- while (i<40);
- });
- });
But instead of every other DIV having a new top value - every DIV is being reduced by 25. I am completely lost and could use come help.