Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Cody House Nav Doesn't Function in IE Reply To: Cody House Nav Doesn't Function in IE

#265232
Shikkediel
Participant

Let me make a variation while I’m at it (middle block of what you’ve posted):

if ($(window).width() > MQL) {
  var headerHeight = $(".cd-header").height();
  $(window).on(
    "scroll",
    {
      previousTop: 0
    },
    function() {
      var currentTop = $(window).scrollTop();
      //leave the function if there is no change
      if (currentTop == this.previousTop) return;
      //check if user is scrolling up
      else if (currentTop < this.previousTop) {
        //if scrolling up...
        if (currentTop > 0 && $(".cd-header").hasClass("is-fixed")) {
          $(".cd-header").addClass("is-visible");
        } else {
          $(".cd-header").removeClass("is-visible is-fixed");
        }
      } else {
        //if scrolling down...
        $(".cd-header").removeClass("is-visible");
        if (currentTop > headerHeight && !$(".cd-header").hasClass("is-fixed"))
          $(".cd-header").addClass("is-fixed");
      }
      this.previousTop = currentTop;
    }
  );
}

I’ve added a line after “//leave the function if there is no change”… no need to go through the rest if the scrolling position is the same. You’re code snippet doesn’t look right by the way, I’m assuming it’s because of a copy and paste.