gpt4 book ai didi

javascript - Waypoints.js,如何重新进行初始检查?

转载 作者:行者123 更新时间:2023-11-28 19:25:14 24 4
gpt4 key购买 nike

我正在构建一个网站,我需要一个可以向下滚动直到没有更多内容的表格,但它一次只会查询大约 50 个条目。所以这有点无限滚动。

我现在遇到的问题是我想重新执行 Waypoints.js 在初始化新航点时所做的初始检查:

"When a waypoint is created, one of the steps in the process is to check if the waypoint has already been passed in the down direction. If it has, the waypoint handler is immediately triggered." - http://imakewebthings.com/waypoints/api/enabled-option/

我想这样做的原因是因为假设我将片段的大小设置为 25 并且它不会填满整个屏幕我永远不会触发航路点事件并获得更多条目。

我设法通过这样做解决了这个问题:

function initWaypoint(){
if($waypoint){
$waypoint.destroy();
}

$waypoint = $("#waypoint").waypoint(function(){
queryFragment();
},{
offset: 'bottom-in-view'
})[0];
}

它会查询更多片段,直到屏幕被填满,但对于我来说,这个解决方案有点太脏了。尽管如此,还是完成了工作,并且没有给我带来任何性能问题。 有更好的方法吗?

最佳答案

您的操作方式正是 Waypoints Infinite Scroll 快捷方式的处理方式,作者:destroying the waypoint然后reinitializing the waypoint一旦加载新项目。

关于javascript - Waypoints.js,如何重新进行初始检查?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28012588/

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