JQuery在滚动问题上添加类

时间:2016-04-09 02:55:50

标签: javascript jquery html scroll

我在滚动代码上添加类有问题...在滚动浏览元素后添加类,而不是在用户开始滚动时将类添加到每个元素。

http://sandbox.viaphase.com/ajs-presentation/

$(document).ready(function() {
    $(window).scroll( function(){

        /* Check the location of each desired element */
        $('.animscroll').each( function(i){
            var bottom_of_object = $(this).offset().top + $(this).outerHeight();
            var bottom_of_window = $(window).scrollTop() + $(window).height();

            /* If the object is completely visible in the window, fade it it */
            if( bottom_of_window > bottom_of_object ){
                $(this).addClass('SlideUp'); //Adds animation class to element
            }

        }); 
    });
});

0 个答案:

没有答案