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