gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 06:01:27 25 4
gpt4 key购买 nike

当 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com