滚动库-到达页面的末端-回调或绑定

iScroll library - end of page reached - callback or binding?

本文关键字:回调 绑定 滚动      更新时间:2023-09-26

我试图挂钩函数回调时,isroll容器到达页面的末尾,在底部(y轴)。这样我就可以按需加载更多的内容,而不是所有的300多个内容。

有人在做吗?有提示吗?

这里是我所指的库:http://cubiq.org/iscroll-4

正如上文提到的,你应该查看Pull来刷新demo

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

你需要建立你自己的逻辑,不需要用户拉来添加更多的项目。

类似于(伪代码-未经测试的代码):

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