【问题标题】:Infinite scroll based on mouse scroll基于鼠标滚动的无限滚动
【发布时间】:2013-03-06 06:46:57
【问题描述】:

想在鼠标到达指定容器底部时基于鼠标滚动实现无限滚动。我是在搜索http://www.infinite-scroll.com/后来到这个插件的,它需要以下基本要求:

// infinitescroll() is called on the element that surrounds 
// the items you will be loading more of
  $('#content').infinitescroll({

    navSelector  : "div.navigation",            
                   // selector for the paged navigation (it will be hidden)
    nextSelector : "div.navigation a:first",    
                   // selector for the NEXT link (to page 2)
    itemSelector : "#content div.post"          
                   // selector for all items you'll retrieve
  });

即下一个和上一个选择器。我们可以基于鼠标滚动无限滚动而不是单击下一步,上一个链接,即当鼠标到达指定容器底部时,通过 ajax 加载内容

【问题讨论】:

  • 你的问题是什么?你已经得到了 infinite-scroll.com ,它正是你想要的。现在呢?
  • 不幸的是,我找不到在鼠标滚动上加载内容的演示 + 示例代码。我不希望 next, prev 链接加载更多内容。
  • @RockySingh 只是一个猜测,但也许它只是想让链接知道在哪里查找下一页数据。也许您可以包含这些链接,但将它们隐藏起来。
  • @RockySingh 该页面本身就是一个演示 :P :D 尝试向下滚动!
  • 你能给它样品吗?

标签: javascript jquery ajax


【解决方案1】:

向滚动事件添加一个函数并检查您是否向下滚动到底部。 您必须根据您的布局调整数字并稍微调整代码:

var $window = $(window);

$(document).ready(function () {

        $(window).scroll(function () {
            var scrollheight2;
            scrollheight2 = $window.scrollTop();

            if (($("#content").height() - scrollheight2) <= 100) {
                    //AJAX STUFF
            }
        });
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-26
    相关资源
    最近更新 更多