JRoy
9/18/2018 - 1:04 PM

Sticky Show on Scroll Up

/* ********************* 
     * Sticky Nav Scroll Up
     ******************** */
    var pos;
    var formEndPoint;
    var prevPos = $('body').scrollTop() || $('html').scrollTop();
    $(window).scroll(function(e) {
        pos = $('body').scrollTop() || $('html').scrollTop();
        // For desktop.
        // Check for when scroll past quickform (in slider, banner, or sidebar).
        if( $('.hero-internal-container').length ) {
            formEndPoint = $('.hero-internal-container').offset().top + $('.hero-internal-container').height();
        }
        else if( $('.hero-homepage-container').length ) {
            formEndPoint = $('.hero-homepage-container').offset().top + $('.hero-homepage-container').height();
        }
        else {
            formEndPoint = 300;
        }
        // Show sticky desktop.
        if(pos > formEndPoint) {
            $('.sticky-nav').addClass('sticky-desktop');
        }
        else {
            $('.sticky-nav').removeClass('sticky-desktop');
        }
        // For Mobile.
        if( pos > prevPos || pos == 0) {
            // Scrolling down, hide sticky mobile.
            $('.sticky-nav').removeClass('sticky-mobile');
        }
        else {
            // Scrolling up, show sticky mobile.
            if( $('.sticky-nav').hasClass('sticky-desktop') ){
                $('.sticky-nav').addClass('sticky-mobile');
            }else{
                $('.sticky-nav').removeClass('sticky-mobile');
            }
        }
        // Set previous scroll position to new scroll position for tracking (of scroll direction).
        prevPos = pos;
    });
@mixin max-lg {
  @media (max-width: 1199px) {
    @content; 
  }
}

.sticky-nav.sticky-desktop {
    @include lg {
        transform: none;
    }
}
.sticky-nav.sticky-mobile {
    @include max-lg {
        transform: none;
    }
}

.sticky-nav {
  position:fixed;
  z-index:9999;
  left:0;
  top:0;
  transform: translateY(-100%);
  transition: transform 0.6s;
  @include transition(0.4s);
}