javascript - 当用户向下滚动时显示 Div

标签 javascript jquery infinite-scroll

我有一个基于另一个 fiddle 的工作演示:http://jsfiddle.net/jackdent/gRzPF/12/

基本上我怎样才能让 div 淡入而不是直接加载。

这是我使用的代码:

$(".reveal").addClass("noshow");
var contentNumber = 0;

function reveal() {
    var constraintNumber = contentNumber + 7;
    //IMPORTANT - DO NOT DELETE
    $(window).trigger('resize');
    //IMPORTANT - DO NOT DELETE
    for (i = contentNumber; i < constraintNumber; i++) {
        //Get the nth div of class content, where n is the contentNumber, and make it shown
        $('.reveal').eq(contentNumber).removeClass("noshow");
        contentNumber ++;
    }
}

//Window scroll function
$(window).scroll(function() {
   if ($(window).scrollTop() == $(document).height() - $(window).height() )
    {
        reveal();
    }
});
reveal();

这是我的工作 fiddle :

http://jsfiddle.net/barrycorrigan/4Ur6R/

我对 jQuery 完全陌生,我从上面的示例中获取了这段代码。它工作得很好,我只是想让 DIV 淡入。

如果您能提供任何帮助以使其正常工作,我将不胜感激。

最佳答案

更改此行:

$('.reveal').eq(contentNumber).removeClass("noshow");

对此:

$('.reveal').eq(contentNumber).fadeIn('300');

300 是出现的时间(以毫秒为单位)。

DEMO

关于javascript - 当用户向下滚动时显示 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21046465/

相关文章:

javascript - 主干模型保存和回调问题

javascript - 不可匀光是什么意思?

javascript - jQuery 选择器仅第一级 div

javascript - javascript 错误,可能是语法?

android - 如何用 RecyclerView 实现无限滚动?

javascript - 在模板文字中定义函数

jquery - 在自定义 JQuery 中嵌套 JQuery UI 选项卡

javascript - 仅当滚动达到某个点时,我如何使用 jquery 显示内容?

jquery - 为什么通过 AJAX 无限滚动加载的内容加载后高度测量不正确?

javascript - 拉斐尔 : specify the spectrum of getColor()