Infinite scrolling with div own

43 views Asked by At

First thanks for the help , I 'm with a problem I can not solve. I have this script which is infinite , however I want it to be infinite using typical of the #main divs , example :

I have divs

<div class="content">1</div>
<div class="content">2</div>
<div class="content">3</div>
<div class="content">4</div>
<div class="content">5</div>

first rises to 5, then 4 , then 3 and so on, endlessly rising from the bottom up , how to accomplish this ?

           infinitely rising <----------------------
<div class="content">3</div> the third to go up --| | 
<div class="content">4</div> the second to rise --| | 
<div class="content">5</div> the first to rise  --  |
           ....                                     |
<div class="content">2</div> -----------------------
<div class="content">3</div> after you [...]
<div class="content">4</div> after you
<div class="content">5</div> first climbs you

my script http://jsfiddle.net/66RvC/70/

1

There are 1 answers

0
matthias_h On

I'm not sure if that's what you want, but just made this Fiddle

function cycle() {
  var dLength = $("div.content").size();
  $(".content").eq(dLength - 1).prependTo($("#main"));
  setTimeout(cycle, 2000);
}

cycle();

based on the assumption that you want a fixed set of divs infinitely rising up/changing places, and this adjustment of your Fiddle - only changed this function:

var d = function(){
  var dLength = $("div.content").size();
  return $(".content").eq(dLength - (i++)).clone();
};

in case you want to add infinite copies/clones of the divs instead.