Waypoints.js,如何重新做初始检查?

Waypoints.js, how to re-do the initial check?

我正在构建一个网站,我需要一个 table 可以向下滚动直到没有更多内容,但它一次只会查询大约 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 无限滚动快捷方式处理它的方式,destroying the waypoint and then reinitializing the waypoint 一旦加载了新项目。