My fadeIn
on scroll seems to be triggering every time I scroll which is what I want. But this queues up the animation and ends up running well after the user has stopped scrolling.
I have tried using the .stop(true, true)
function but I believe this does not work on a if
or else
statement.
My code so far:
if($('.icon').isOnScreen()){
$('.icon').fadeIn("slow");
} else {
$('.icon').fadeOut("slow");
};
I have tried below but this does not work
if($('.icon').isOnScreen()){
$('.icon').stop(true,true).fadeIn("slow");
} else {
$('.icon').stop(true,true).fadeOut("slow");
};