Jquery无法触发第二个滚动事件

时间:2015-04-21 13:46:35

标签: jquery scroll jquery.visible

我正在尝试使用.visible()获取$(window).scroll以触发第二个元素。但是,如果我像我在下面所做的那样写它,或者甚至将它们放在单独的代码块中,这些代码块中的任何一个都处于顶层,而下面的代码块并没有。似乎window.scroll仍在等待第一个事件发生并忽略第二个事件?

   //***********************************************************
        // TEST ELEMENTS ARE IN VIEWPORT
        //***********************************************************
        $(window).scroll(function(){
            if ($("#moreSection").visible(true)){
                $(".slideInLeft").delay(400).show("slide", { direction: "right", easing: 'easeOutBounce'}, 400);
            }else if($("#why-use-section").visible(true)) {
                $(".slideInLeft2").delay(400).show("slide", { direction: "right", easing: 'easeOutBounce'}, 1600);
            }

        });

1 个答案:

答案 0 :(得分:0)

可能不是正确的解决方案,但基于此:Wait till a Function with animations is finished until running another Function

function ScrollOne(){
    if ($("#moreSection").visible(true))
        $(".slideInLeft").delay(400).show("slide", { direction: "right", easing: 'easeOutBounce'}, 400);
}

function ScrollTwo(){
    if($("#why-use-section").visible(true)) {
        $(".slideInLeft2").delay(400).show("slide", { direction: "right", easing: 'easeOutBounce'}, 1600);
}

$(window).scroll(function(){
    ScrollOne().done(ScrollTwo());
});
相关问题