2

I'm trying to hook function callback when iScroll container reaches end of page, at the bottom end (Y-axis). So that I can load more content on demand - instead of all 300+ contents.

Has anybody worked on it? Any hints?

Here is the library I was referring to: http://cubiq.org/iscroll-4

Hossain Khan
  • 6,332
  • 7
  • 41
  • 55
  • iScroll 4 has some extra features that allow you to implements pull-down and/or pull-up to reload content. See the section on "Pull to refresh" http://cubiq.org/iscroll-4 – drmatt Dec 14 '11 at 14:01

1 Answers1

1

As drmatt metioned, you should look into Pull to refresh demo

http://cubiq.org/dropbox/iscroll4/examples/pull-to-refresh/

You need to build you own logic which won't require user to pull to add more items.

Something like following (pseudo code - not tested code):

var isAlreadyLoading = 0;
var iscroller = new iScroll(
'your-element-id', 
  { 
    hScroll: false, 
    bounce: false, // do not bounce
    onScrollMove: function () {
      // CHECK if we've 350px gap before reaching end of the page
      if ( (this.y < (this.maxScrollY + 350)) && (isAlreadyLoading == 0) ){ 
        // start loading next page content here

        // update this flag inside load more and set to 0 when complete
        isAlreadyLoading = 1; 
      }
    },
    onScrollEnd: function () {
      // check if we went down, and then load content
      if ( isAlreadyLoading == 0 ) {
        // Load more content

        // update this flag inside load more and set to 0 when complete
        isAlreadyLoading = 1; 
      } else {
        // DO NOTHING
      }
    }
  } // end of Scoller config object
); // end iScroll instance
Hossain Khan
  • 6,332
  • 7
  • 41
  • 55