2013-01-16 78 views
2

是否有推荐的方式去jQuery移动应用程序中的惰性加载/无限滚动内容,我怎么能在个人“页面”上做到这一点?jQuery的移动滚动事件到延迟加载内容

我应该在页面的页面展示中定义一个滚动事件函数吗?如下所示?

$(document).delegate("#a_jquery_page", "pageshow", function() { 

    $(window).scroll(function(){ 
     //check scroll position and load content 
    }); 
}); 

或者我应该使用setInterval函数检查滚动位置每秒或半秒或什么?

回答

1

每次窗口滚动时都会调用.scroll事件,您只需在该函数中检查窗口位置即可。间隔功能没有理由。

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

    if (scrollTop == ....) { <code> } 
}