jqueryjquery-mobileiscroll4

auto scroll when content goes to maximum height of div


How do I start auto scrolling when the content goes to maximum height of a div? I am getting alert when I am at the end of the div, but is it possible to start auto scrolling?

Here is my fiddle.

http://jsfiddle.net/naveennsit/JpvAy/

I found the end point of div like this:

 myScroll = new iScroll('wrapper', {
              onScrollEnd: function() {
                    if(($('#wrapper').offset().top - $('#scroller').offset().top) + $('#wrapper').height() >= $('#scroller').height()){
                        alert('the end');
                    }                        

              }
        });

But I need to start auto scrolling when data is taller than height.


Solution

  • use this after reresh

    myScroll.scrollTo(0, myScroll.maxScrollY, 0);
    

    and also you should learn how to make fiddle so it's easy to understand the code

    here is our updated fiddle