0

I am trying to get $(window).scroll to fire on a second element using .visible(). But if i write it like i have done below or even put them in separate code blocks, which ever one is on top fires and the one underneath doesn't. It seems like window.scroll is still waiting for the first event to happen and ignores the second one?

   //***********************************************************
        // 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);
            }

        });
Cobote
  • 385
  • 2
  • 12
user3358014
  • 97
  • 1
  • 9

1 Answers1

0

Probably not the right solution, but based on this: 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());
});
Community
  • 1
  • 1
Razorphyn
  • 1,314
  • 13
  • 37