-1

The below code changes the orientation of my navigation by adding/removing a class name. How can I make it fade in and out when the orientation occurs? Here's my code:

$(window).scroll(function() {
    ($("#another-reason-to-attend").offset().top <= window.pageYOffset) ? $("#prim").addClass("horizontal") : $("#prim").removeClass("horizontal");
    ($("#another-reason-to-attend").offset().top <= window.pageYOffset) ? $("#logo").addClass("small") : $("#logo").removeClass("small");
});

EDIT

I've tried adding .fadeIn and .fadeOut to the lines above but it just breaks.

Example:

 ($("#another-reason-to-attend").offset().top <= window.pageYOffset) ? $("#prim").addClass.fadeIn("horizontal") : $("#prim").removeClass.fadeOut("horizontal");
egr103
  • 3,858
  • 15
  • 68
  • 119

1 Answers1

0

not sure what are you trying to fadeIn and fadeOut.. asuming this is what you want

try this

 ($("#another-reason-to-attend").offset().top <= window.pageYOffset) ? $("#prim").addClass("horizontal").hide().fadeIn() : $("#prim").removeClass("horizontal").fadeOut();
  ...

since fadeIn() works only for hidden elements, hide it is first(if not hidden )

bipen
  • 36,319
  • 9
  • 49
  • 62