检测页面底部的死滚动(鼠标滚轮、滚动事件)

Detect dead scrolling at the bottom of the page (mousewheel, scroll events)

我正在寻找检测用户何时滚动到页面底部然后尝试继续滚动但什么都没有 scroll/view。

我正在创建可用性指标,其中死滚动是一个指标,需要一种方法来准确检测用户何时尝试滚动但没有提供任何剩余内容。

我需要在鼠标滚轮事件启动但页面不滚动时触发的东西,up/down 方向。

添加 windows scrollTop() 和高度。如果它等于文档高度,则您位于页面底部。

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       console.log("Page bottom reached!");
   }
});

http://jsfiddle.net/1v3cakn9/1/

这是我用来在到达底部时阻止页面动画滚动的脚本的作用:

var gate = $(window), edge;
setLength();

gate.resize(function() {
  setLength();
});

function setLength() {
  edge = $(document).height()-gate.height();
}

gate.mousewheel(function(event, delta) {

    outset = gate.scrollTop();
    if (delta == 1 && outset == 0 ) console.log('top');
    if (delta == -1 && outset == edge) console.log('bottom');
});

我正在使用 mousewheel 插件,它非常棒,要获得任何良好的跨浏览器支持,您无论如何都必须编写一堆代码来规范化滚轮事件...

https://plugins.jquery.com/mousewheel/

我猜这会完成问题中提出的问题 - 检测鼠标滚轮事件是否会使页面滚动超出其限制。对于思想实验,尽管您也可以领先一步,但只有在将 mousewheel 用作 setter 时才能准确。当用户触发鼠标滚轮事件时,可以使页面滚动精确数量的像素。当页面的目的地已知时,您可以检查它是否在到达页面顶部或底部的范围内。