javascript - iScroll 库 - 到达页面末尾 - 回调或绑定(bind)?

标签 javascript iscroll4

当 iScroll 容器到达页面末尾时,我正在尝试 Hook 函数回调,位于底部(Y 轴)。这样我就可以按需加载更多内容 - 而不是所有 300 多个内容。

有人做过吗?有什么提示吗?

这是我指的图书馆:http://cubiq.org/iscroll-4

最佳答案

正如 drmatt 提到的,您应该查看 Pull to refresh 演示

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

关于javascript - iScroll 库 - 到达页面末尾 - 回调或绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8243934/

相关文章:

javascript - 使用 jQuery 将表情符号插入 div 中

jquery-mobile - 与内容分开滚动 JQuery Mobile 面板

javascript - 由于 javascript jQuery 创建的容器 CSS,iScroll 4 停止工作

javascript - 某些 sIFR 选择器在 Safari 中不起作用——非常不寻常的错误 :

javascript - 异步函数

javascript - Sencha Touch 2.1 点击整个工具栏

javascript - 从表中删除行、deleteRow(id)、remove() 或在 Reactjs 中使用 useState()

javascript - iScroll 在一个轴上进行原生滚动

jquery - 使用 iscroll 与 jquery 移动绑定(bind)问题

javascript - iscroll 问题与二维(水平+垂直)滚动、可滚动是否相关?