Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iScroll lite find when I have reached the end of the scroll or bottom of the element

Ok I've been searching and searching for an answer, but have yet to find one in the general area I am looking for. Not being supremely familiar with iScroll (a former developer on this project added it in, and I am now taking it over). I have been trying to figure out where to begin with iScroll.

Right now all seems to work accordingly as far as scrolling up and down. But I want to add some functionality to the overall app thats been developed, such as getting older data and appending it to the more recent data thats listed at that time. An infinite scroll.

Pulling in the data via ajax, and working with it to append it to and refresh iScroll length isn't so much the issue (I think, well for the moment at the least). What is my issue is finding that moment when the bottom is reached and firing off the function I will make to get said data and append it.

I can't find any examples anywhere so I am hoping someone here can throw me some ideas

like image 278
chris Avatar asked Dec 12 '12 11:12

chris


1 Answers

Since this question is pretty old. This solution is for any future references.

Using iScroll v4.2.5:

var scroll = new iScroll('scroll-wrapper');
scroll.options.onScrollEnd = function(){
    if(Math.abs(this.maxScrollY) - Math.abs(this.y) < 10){
        // RUN CODE if scroll is 10px from the bottom.
    }
};
like image 97
AlexCheuk Avatar answered Nov 15 '22 05:11

AlexCheuk